PDA

View Full Version : deleting option object -- Please Help!


Meggie
05-02-2003, 07:05 PM
Can someone please help ... Basically, in the function, I am trying to re-initialize the option list so that I can create another option list.

fruits is Select box.

These are the codes:

for(i=0;i <old_size; i++) {
form.fruits.options[i] = null; // [COLOR=orangered]this doesn't work somehow !!! :confused:

} //[COLOR=darkred]but if I do this, it'll work: form.fruits.options[1] = null; I mean if it's not a variable, then it'll work.

//the creation is working fine:
for(i=0;i<new_size; i++){
form.fruits.options[i] = new Option(value, value);
}


Thank you so much for your help.

Meggie
05-02-2003, 07:31 PM
I went through this forum and found out this:

for (m=temp.options.length-1;m>=0;m--)
temp.options[m]=null



It works. It's weird because if incrementing, it won't work but decrementing, it'll work.

tamienne
05-02-2003, 09:41 PM
you can get incrementing to work like this...


for(i=0;i <old_size; i++) {
form.fruits.options[0] = null;
}


what you were doing before was deleting ones that were already deleted...