|
-
June 3rd, 2008, 05:34 AM
#1
something wrong with iteration
Can anyone see anything wrong with this excerpt of code.
When I use alert(workingstructurewithdivid.length);
I get 111 but it only seems to be going through the code once and stopping
Edit: I'm getting an 'undefined' is null or not an object error but it only comes up some of the time so something in the checks must be null and causes it to fall over. Any ideas how to check?
Code:
else if (document.getElementById("Division").value >= 1) {
for (i = 0; i < workingstructurewithdivid.length; i++) {
var optn = document.createElement("OPTION");
optn.text = workingstructurewithdivid[i].substring(0,5);
optn.value = workingstructurewithdivid[i];
alert(i);
alert ("DIV:" + document.getElementById("Division").value);
alert (optn.value.substring(6,7));
if ((document.getElementById("Division").value == optn.value.substring(6,7))
&& optn.text != workingstructurewithdivid[i-1].substring(0,5)) { //dup check
document.getElementById("BusUnitLevels").options.add(optn);
}
}
}
Last edited by JACKWEBS; June 3rd, 2008 at 05:43 AM.
-
June 3rd, 2008, 08:25 AM
#2
Re: something wrong with iteration
It's hard to tell without more working code. We can't test it out.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|