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

for loop and getElementByID

Status
Not open for further replies.

TimeTraveler

IS-IT--Management
Nov 20, 2001
99
US
I'm building this filter for an event lister. My idea is to do it client side with JavaScript hiding and showing div tags labels by two-letter state code. It was such a simple idea... Of course, I get hung up on handling objects and methods, as usual.

Thanks in advance to anyone who can tell why I'm getting an error on getElementById and why this won't go. I get the following error in IE regarding the line with getElementById:
Error: Object doesn't support this property or method.

Code:
<SCRIPT type=text/javascript>
 st = new Array(
 "AK", "AL", "AR", "AZ", "CA", 
 "CO", "CT", "DC", "DE", "FL", 
 "GA", "HI", "IA", "ID", "IL", 
 "IN", "KS", "KY", "LA", "MA",
 "MD", "ME", "MI", "MN", "MO", 
 "MS", "MT", "NC", "ND", "NE", 
 "NH", "NJ", "NM", "NV", "NY", 
 "OH", "OK", "OR", "PA", "PR", "RI", 
 "SC", "SD", "TN", "TX", "UT", 
 "VA", "VT", "WA", "WI", "WV", "WY");

function hideAllStates() {
 for(i = 0; i<st.length; i++) {
  document.getElementByID(st[i]).style.display = "none";
 }
}
</SCRIPT>

Somehow, I'm missing how to get the contents of all the elements of st[] into the getElementByID.

Sean aka TimeTraveler [rockband]

Visit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top