PDA

View Full Version : small form problem- storing a normal list in an array


tusick2c
02-24-2004, 03:34 AM
hi everyone,

I seem to be having a small problem in my html form. When i try to simply get the contents of my list and put it in an array using javascript, each element of the list is empty...

so i looked at the contents of each item in the list...and it said it showed each item to be empty ..even though i can visually see stuff in the list..(btw i did this by using alerts(document.uRemove.uploader.options[i].value); (uRemove is the form name, uploader is the list name) and
([i] being any element in the list).

So currently ive got no idea what the problem is...maybe im not writing the correct code to acess each list item
ie. im writing document.formName.listName.options[i].value
is that right? I also attached my code if that helps

ill appreciate any help...thanks in advance

tusick2c
02-24-2004, 03:40 AM
sorry i forgot to attach it...its in this message's attachment

-------------------------------------------------------
hi everyone,

I seem to be having a small problem in my html form. When i try to simply get the contents of my list and put it in an array using javascript, each element of the list is empty...

so i looked at the contents of each item in the list...and it said it showed each item to be empty ..even though i can visually see stuff in the list..(btw i did this by using alerts(document.uRemove.uploader.options[i].value); (uRemove is the form name, uploader is the list name) and
([i] being any element in the list).

So currently ive got no idea what the problem is...maybe im not writing the correct code to acess each list item
ie. im writing document.formName.listName.options[i].value
is that right? I also attached my code if that helps

ill appreciate any help...thanks in advance

agent002
02-24-2004, 05:37 AM
The problem is in the following part of the script:
Ulist.options[newItem] = new Option(currentfile);
By only giving one argument, you don't give the <option> any value. So to solve the problem, simply use this code instead:
Ulist.options[newItem] = new Option(currentfile, currentfile);

tusick2c
02-24-2004, 06:59 AM
thanks...it worked