vrachos
01-14-2004, 02:35 AM
I'm currently working on a project where i'm making a select box. then i do a for loop on the selectbox so i can set a selected item(this is stored in a database and parsed to the function).
------The Code-------------------
fieldCounter++;
dropdownName = numtoChar(fieldCounter-1);
dropdownName = dropdownName + "int_chapter_id";
for(i = 0; i <= document.getElementById(dropdownName).options.length; i++){
if(document.getElementById(dropdownName).options[i].value == content){ //here is the error
document.getElementById(dropdownName).options[i].selected = true;
}else{}
}
-------End of the code-------------
I've search for the error in the script(tested with commenting the rest out) and i think the error is in the if statment.
The error I get is: 'document.getElementById(...).options[...].value' is empty or not an object.
The script however work fine exept for that is displays the error.
Above this script is a piece of script that created a new row in a table and a cell with the selectbox is this maybe the problem. Or is it something else.
I'm getting the error in Internet Explorer I haven't tested it on other browsers yet
------The Code-------------------
fieldCounter++;
dropdownName = numtoChar(fieldCounter-1);
dropdownName = dropdownName + "int_chapter_id";
for(i = 0; i <= document.getElementById(dropdownName).options.length; i++){
if(document.getElementById(dropdownName).options[i].value == content){ //here is the error
document.getElementById(dropdownName).options[i].selected = true;
}else{}
}
-------End of the code-------------
I've search for the error in the script(tested with commenting the rest out) and i think the error is in the if statment.
The error I get is: 'document.getElementById(...).options[...].value' is empty or not an object.
The script however work fine exept for that is displays the error.
Above this script is a piece of script that created a new row in a table and a cell with the selectbox is this maybe the problem. Or is it something else.
I'm getting the error in Internet Explorer I haven't tested it on other browsers yet