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

I am trying to clear an option box

Status
Not open for further replies.

caseye

IS-IT--Management
Feb 7, 2002
52
US
I am trying to clear an option box the following loop works but only clears the firs two entries then

SelSitesLength = document.reportbuilder.SelSites.options.length;

for(i = 0; i < document.reportbuilder.UnSelSites.options.length; i ++)
{
site = null;
siteSplit = null;
if(document.reportbuilder.UnSelSites.options !== null)
{
site = document.reportbuilder.UnSelSites.options.value;
siteSplit = site.split(&quot;,&quot;);
if(siteSplit[0] = state)
{
document.reportbuilder.UnSelSites.options = null

}
}
}
 
Please enclose your code in [ code ] and [ /code ] tags (without the spaces). Especially if you use i as an array subscript. Mainly because
Code:
[i]
is the TGML tag to turn on italics, which is why your code turns italic halfway thru. If you use the code tags, you can say
Code:
[i]
with no problem. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Code:
for(i = 0; i < document.reportbuilder.UnSelSites.options.length; i ++) {
 site = null;
 siteSplit = null;
 if(document.reportbuilder.UnSelSites.options[i] !== null) {
  site = document.reportbuilder.UnSelSites.options.value;
  siteSplit = site.split(&quot;,&quot;);
  if(siteSplit[0] = state) {
   document.reportbuilder.UnSelSites.options = null
  }
 }
}
Line 4, where you see
Code:
 if(document.reportbuilder.UnSelSites.options[i] !== null)
The condition be
Code:
!=
rather than
Code:
!==
And nested within it, line 7
Code:
  if(siteSplit[0] = state)
That condition should be
Code:
==
rather than
Code:
=
Further than that, I can't help unless you provide more code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top