Javascript text
-
Sorry about the useless subject line. Say I have two buttons. Is there anyway I can use javascript, to change text displayed on the screen, depending on which button I use? If so, please let me know what it is.
Use a span or something, and set the innerHTML:
<span id="Thing">Text</span> <script> function SetText(id, text) { document.all[id].innerHTML = text } </script> <input type=button onclick="SetText('Thing', 'Hello World');>
Untested, but is more or less what you want to get started. -- Ian Darling If I was any more loopy, I'd be infinite.
-
Use a span or something, and set the innerHTML:
<span id="Thing">Text</span> <script> function SetText(id, text) { document.all[id].innerHTML = text } </script> <input type=button onclick="SetText('Thing', 'Hello World');>
Untested, but is more or less what you want to get started. -- Ian Darling If I was any more loopy, I'd be infinite.
But don't use an IE only DOM 0 thingy (hint:
document.all
) if it's possible to stay compatible with most (actually all) browsers by usingdocument.getElementById(id).innerHTML = text;
. -
But don't use an IE only DOM 0 thingy (hint:
document.all
) if it's possible to stay compatible with most (actually all) browsers by usingdocument.getElementById(id).innerHTML = text;
.