Click to See Complete Forum and Search --> : document.write() from onchange


arthur
10-11-2003, 10:45 AM
I want to put an onchange event in a link that will pass a var to a document.write() function in another part of my document. The page will have several of these links, each with its own message, but write that message in only one place in my document. I have not got this working. Can someone help?

Thanks
Arthur

Khalid Ali
10-11-2003, 10:50 AM
document.write should not be used unless you know exactly hwo the logical flow of your program works.
What happens after the page is loaded,if you use document.write it writes on the currently loaded document,hence making previous code in accessible for you.
A better choice will be to declare a div element where you want the text to appear,give it an id attribute, then use
document.getElementById("id").innerHTML = value;

arthur
10-11-2003, 11:16 AM
thanks Khalid Ali, you just explained why I was having a problem. I will try your suggestion.

Khalid Ali
10-11-2003, 11:42 AM
you are welcome...:D

arthur
10-13-2003, 09:58 AM
Hi Kalid

Thanks for your reply but I am still unable to make this script work. I was hoping you could help a bit more.

I am trying to send a value via a click on a link w/ onchange event to a div in another part of the document. I tried to use the script you offered above in the head/script, but I just don't know how to send that value to my div.

Many Thanks
Arthur

TomDenver
10-13-2003, 10:32 AM
Arthur, someone had a similar problem in another thread. You may want to read this: http://forums.webdeveloper.com/showthread.php?s=&threadid=19064

arthur
10-13-2003, 11:03 AM
Kalid and everyone else

Yes it works for me. Now I will spend some time figuring out what it is doing.

Thanks
Arhtur