Click to See Complete Forum and Search --> : Writing to a particular area of page


rhattb
11-27-2002, 10:23 AM
I have a page with an imagemap on it. When the user selects a particular area, I want to show various details relating to that area beneath the map.

I'm using Javascript to process the imagemap results, all of which I can do OK, except that I can't get the results to display beneath the map. They always come up onto a new page.

I don't want to write into a textbox or textarea, I need to write into a 'free' area, such as between <SPAN> or <DIV> tags. I can't get the syntax right to do this. I've tried all the combinations of document.write, document.formname.write, etc. that I can think of, but can't get it to work. I also need to write HTML into the same area.

Any help would be appreciated.

Rob

ge0rg1e
11-27-2002, 10:41 AM
Rob,

Check out this message:

http://forums.webdeveloper.com/showthread.php?s=&threadid=169

Heidi

rhattb
11-28-2002, 10:00 AM
Heidi

thanks for that. I hadn't seen the getElementById method before.

I can now use it to insert the values I want to put into the <SPAN> tags, but I still can't get the syntax right to put HTML in there as well. The results going into these <SPAN> tags consist of a set of radio buttons, the number determined by the area clicked on the imagemap. So I need to put both form and radio-button HTML tags inside the <SPAN> tags also.

gil davis
11-28-2002, 10:17 AM
document.getElementById("someID").innerHTML = "<form><input type='radio'></form>"

Supported by IE 5+, NS 6+, and Mozilla. It is not W3C DOM compliant, but it is a suggested addition.

Otherwise, it gets kind of long:

var fm = document.createElement("FORM");
var radio = document.createElement("INPUT");
radio.type = "RADIO"; // unsure of this bit
fm.appendChild(radio);
document.getElementById("someID").appendChild(fm);

Not tested, but I hope you get the idea. :D