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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referring to an object dynamically

Status
Not open for further replies.

jms8142

IS-IT--Management
Dec 3, 2001
16
US
hello,
I have a number of html tables created in an asp file that are enclosed by <div></div> tags. Each successive <div> tag includes an id attribute that increments by 1 for each section. (e.g. id = &quot;report0&quot;, id = &quot;report1&quot;, id = &quot;report2&quot;).
What I'm doing is using these divisions to hide the table within them by calling the following javascript function:
report0.style.display = &quot;none&quot;;

since there can be hundreds of sections, based on the records returned, I need to make this function dynamic, something like:

for (var i = 0; i < totalcount; i++) {
[&quot;report&quot; + i].style.display = &quot;none&quot;;
}

but this doesn't seem to work. Anyone have any ideas? thanks.
 
use document.getElementById for standard compliancy and to fix your problem.

for (var i = 0; i < totalcount; i++) {
document.getElementById(&quot;report&quot; + i).style.display = &quot;none&quot;;
}

Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top