the_bob
03-20-2004, 07:35 PM
ok, i'm using document.write to show the value of a variable.
document.write("Variable 1 equals " + (variable 1) + " .");
if the value of variable 1 changes, how do I get it to say the new value?
Antoniohawk
03-20-2004, 09:23 PM
After it has already been written to the page you would have to use innerHTML (http://www.mozilla.org/docs/dom/domref/dom_el_ref8.html).
peasantry
03-21-2004, 08:03 AM
<script>
function add(){
a.innerHTML=eval(a.innerHTML)+1;
}
</script>
<button onclick=add()>click me</button>
<div id="a">1</div>
the_bob
03-21-2004, 05:23 PM
is there something i can use instead of document.write that would automattically change it as soon as it changes? i dont want to have to resort to alert messages. Would a text field change instantly?
Willy Duitt
03-21-2004, 05:29 PM
Originally posted by the_bob
is there something i can use instead of document.write that would automattically change it as soon as it changes? i dont want to have to resort to alert messages. Would a text field change instantly?
Yes, just as Antonio said. innerHTML!
Code?
.....Willy
the_bob
03-21-2004, 05:34 PM
Originally posted by peasantry
<script>
function add(){
a.innerHTML=eval(a.innerHTML)+1;
}
</script>
<button onclick=add()>click me</button>
<div id="a">1</div>
wouldn't that make it so you would have to click a button???
the_bob
03-21-2004, 05:38 PM
oh, just realised that Inner HTML was a link
i'll go check that out now