...

View Full Version : Dynamic List won't remember last setting.



idobson
05-08-2005, 07:04 AM
Ok, what I've got is 2 boxes on the screen, and depending on what you choose in box 1 it populates the list in warranty_itemclss with the correct options for that class.
Problem is, next time I go back to that record and pull it up, as soon as I go to edit the record it clears the value for warranty_itemclss and if you click save the record is saved without the value that the record previously had.

What am I doing wrong? I posted the code below.



function ClearOptions(OptionList) {
// Always clear an option list from the last entry to the first
for (x = OptionList.length; x >= 0; x = x - 1) {
OptionList[x] = null;
}
}

if (this.value=='AV')
{
// Clear out the list
ClearOptions(warranty_itemclss);
// fill the list
warranty_itemclss.options.add(new Option('Television', 'Television'));
warranty_itemclss.options.add(new Option('Big Screen Television', 'Big Screen Television'));
warranty_itemclss.options.add(new Option('VHS Recorders', 'VHS Recorders'));
}
if (this.value=='CO')
{
// Clear out the list
ClearOptions(warranty_itemclss);
// fill the list
warranty_itemclss.options.add(new Option('CPU', 'CPU'));
warranty_itemclss.options.add(new Option('Monitor', 'Monitor'));
warranty_itemclss.options.add(new Option('Printer', 'Printer'));
}
if (this.value=='GM')
{
// Clear out the list
ClearOptions(warranty_itemclss);
// fill the list
warranty_itemclss.options.add(new Option('Toaster', 'Toaster'));
warranty_itemclss.options.add(new Option('Kitchen Centres', 'Kitchen Centres'));
warranty_itemclss.options.add(new Option('Vacuum Cleaners', 'Vacuum Cleaners'));
}
if (this.value=='PE')
{
// Clear out the list
ClearOptions(warranty_itemclss);
// fill the list
warranty_itemclss.options.add(new Option('Digital Camera', 'Digital Camera'));
warranty_itemclss.options.add(new Option('Film Camera', 'Film Camera'));
warranty_itemclss.options.add(new Option('Camcorder', 'Camcorder'));
}

shnplr
05-08-2005, 03:47 PM
for (x = OptionList.length - 1; x >= 0; x--) {

glenngv
05-09-2005, 05:44 AM
Or you can just set the option length to 0.

OptionList.length = 0;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum