M
Margaret MacDonald
I'm a js novice trying to teach myself. I'm using Flanagan's
'Javascript, the definitive guide' from O'Reilly as a text. But
either I'm dopier than usual or its layout doesn't match my learning
style very well, because I seem to be having a dreadful time getting
to grips with even the simplest things.
Currently, I'm trying to change the text that follows a <p> element in
a little test program. My test program has a table with two <td>
elements, each having a <p> and a <textarea>, and a function swap()
that looks at the .value of the <textarea> and, if it's not zero,
copies the value to the other <textarea> and zeroes the current one
out. That part works fine--I can click the button and move the text
back and forth as much as I like.
Trying to do the same thing with the <p> text works up through the
part where I assign the new text to the .data property. But the
display doesn't then update, it just sits there. I can watch the text
move back and forth between the two <textareas>, but there's no
corresponding change at all in the two <p> elements.
Am I not understanding some key piece? Could my browser (Opera7) be
broken?
Any insights greatly appreciated!
Margaret
(here's half the function)
var s,p ;
if ( document.test.leftta.value > "")
{
// copy it to the right side
s = String(document.test.leftta.value) ;
document.test.rightta.value = s.toLowerCase() ;
p = document.getElementById("rightp") ;
if ( p )
{
p.data = s.toString() ;
document.test.rightta.value += "\n"+p.data ;
}
else { document.test.rightta.value += "\nbugger!" ; }
// clear out the left side
document.test.leftta.value = "" ;
p = document.getElementById("leftp") ;
p.data = "" ;
}
'Javascript, the definitive guide' from O'Reilly as a text. But
either I'm dopier than usual or its layout doesn't match my learning
style very well, because I seem to be having a dreadful time getting
to grips with even the simplest things.
Currently, I'm trying to change the text that follows a <p> element in
a little test program. My test program has a table with two <td>
elements, each having a <p> and a <textarea>, and a function swap()
that looks at the .value of the <textarea> and, if it's not zero,
copies the value to the other <textarea> and zeroes the current one
out. That part works fine--I can click the button and move the text
back and forth as much as I like.
Trying to do the same thing with the <p> text works up through the
part where I assign the new text to the .data property. But the
display doesn't then update, it just sits there. I can watch the text
move back and forth between the two <textareas>, but there's no
corresponding change at all in the two <p> elements.
Am I not understanding some key piece? Could my browser (Opera7) be
broken?
Any insights greatly appreciated!
Margaret
(here's half the function)
var s,p ;
if ( document.test.leftta.value > "")
{
// copy it to the right side
s = String(document.test.leftta.value) ;
document.test.rightta.value = s.toLowerCase() ;
p = document.getElementById("rightp") ;
if ( p )
{
p.data = s.toString() ;
document.test.rightta.value += "\n"+p.data ;
}
else { document.test.rightta.value += "\nbugger!" ; }
// clear out the left side
document.test.leftta.value = "" ;
p = document.getElementById("leftp") ;
p.data = "" ;
}