This piece of code is from a JavaScript. The function createOpts takes one
or more SELECT objects as arguments.
function createOpts(sel) {
var s = new Array();
var num = 0;
var n = sel.selectedInd ex;
var args = createOpts.argu ments.length;
for(var i=1;args>i;i++) {
s[i-1] = document.getEle mentById(create Opts.arguments[i]);
if(s[i-1]==sel)num=i;
}
if(args>1){
if(s[num])sel = s[num];
else return;
}
....
....
....
....
}
I don't get the last line in the for-loop. How can one of the arguments that
are stored in array "s" equal "sel"?
In the if statment I can't see how "s[num]" can evaluate to true or false.
or more SELECT objects as arguments.
function createOpts(sel) {
var s = new Array();
var num = 0;
var n = sel.selectedInd ex;
var args = createOpts.argu ments.length;
for(var i=1;args>i;i++) {
s[i-1] = document.getEle mentById(create Opts.arguments[i]);
if(s[i-1]==sel)num=i;
}
if(args>1){
if(s[num])sel = s[num];
else return;
}
....
....
....
....
}
I don't get the last line in the for-loop. How can one of the arguments that
are stored in array "s" equal "sel"?
In the if statment I can't see how "s[num]" can evaluate to true or false.
Comment