Forum Moderators: open

Message Too Old, No Replies

document.write a string value to an id's value

         

sublimity

12:09 am on Jul 25, 2007 (gmt 0)

10+ Year Member



I have an array of different string values and I am trying to figure out how I can write the value of the selected string to a specific id on the page. The id is not part of a form and I cannot call the function from the location of the id since I am trying to fire off the function from one location and cause several changes on the page as a result. I would like to have the exact same result as if I were using the document.write() method; however, I need to be able to specify where the string is written on the page (specifically, to the id's location). Does anyone have any suggestions?

DrDoc

1:25 am on Jul 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



By an "id" I assume you mean something like:
<div id="mydiv"></div>

If so, yes that is very much possible (and easy too).

document.getElementById('mydiv').innerHTML = 'your html goes here';

sublimity

3:06 am on Jul 25, 2007 (gmt 0)

10+ Year Member



That worked perfectly! Thank you!