Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing dynamic div property created using innerHTML

Status
Not open for further replies.

hererxnl

Technical User
Jul 8, 2003
239
US

Hey all,

I'm collecting html from XML files in a loop to dynamically create divs based on user selections:
Code:
for (var i = 0; i < markers.length; i++) {
	currentlocation_html += '<div class="currentlocation" id="currentlocation' + (i + 1) + '">' + GXml.value(markers[i].getElementsByTagName("details")[0]) + '</div>';
}
then writing the html inside a div container:
Code:
document.getElementById("locationcontainer").innerHTML = currentlocation_html;
By default, they are styled by my css class to have a display property of none (display:none;).

When I try to change the property with javascript:
Code:
document.getElementById("currentlocation" + i + "").style.displaydisplay.value="inline";
I get an error stating the element has no properties.

I assume that this is because the divs are not hard coded in my html and the javascript doesn't "see" the div. Am I right? Is there a way around this?

All help is greatly appreciated, thanks in advance.

 

Sorry for the fishing question but I was getting desperate. As expected it was a stupid error. For loop exceeded divs created.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top