Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2005
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic List won't remember last setting.

    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'));
    }

  • #2
    New Coder
    Join Date
    May 2005
    Location
    Sydney, Aust
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    for (x = OptionList.length - 1; x >= 0; x--) {

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Or you can just set the option length to 0.

    OptionList.length = 0;
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •