| Author |
Modifying Text in a DIV
|
Justin Fox
Ranch Hand
Joined: Jan 24, 2006
Posts: 802
|
|
ok i have a text field that the user inputs a value into. then i take that value and set another textfield value equal to the one that user input into. but in a textfield, you cant modify the font-face,font-size or color or alignment. But in a DIV you can. how do i go about getting and putting text into a div? I've tried getting its "value" and i tried .write() to the variable of the div, and that doesnt work either. i want this function to work in atleast firefox and ie. please help, Thanks, Justin Fox
|
You down with OOP? Yeah you know me!
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
|
|
Trying random things that might or might not work isn't a very effective strategy. get yourself a good JavaScript and DOM reference. In it you would discover the innerHTML property.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Justin Fox
Ranch Hand
Joined: Jan 24, 2006
Posts: 802
|
|
document.all.div2.innerHTML = "More random text."; that isnt supported by all browsers... im doing more than just trying random things. Justin Fox
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
|
|
"I tried value and I tried write()" seems pretty random to me. I'm not saying this to be mean or anything, but to help you develop a better methodology to getting things doen. What reference are you using? document.all is an IE-only mechanism that should never be used. Use the standard document.getElementById() method.
|
 |
Justin Fox
Ranch Hand
Joined: Jan 24, 2006
Posts: 802
|
|
k, i fixed that problem, now i have another one. when i do my style sheet, the background color and border for the div show up in i.e. But i need it to show up in mozilla too, but it doesn't. instead of using: background-color:#E8E8E8; should i use: background:#E8E8E8; likewise, instead of using the: border-style:black 2 px; should i use border:2px maybe mozilla doesnt recognize the first ones, but will recognize the second. Thanks, Justin Fox
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
|
|
Now it's time for you to find a CSS reference. Once again you are trying random patterns until you find one that works, rather than looking up what the valid syntax should be. In order to be an effective page author, you need the ability to look up syntax rather than just try different things until it works. This is an essential skill that must be developed. [ October 23, 2007: Message edited by: Bear Bibeault ]
|
 |
 |
|
|
subject: Modifying Text in a DIV
|
|
|