#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    Chicago, IL
    Posts
    85
    Rep Power
    13

    Please help with this Javascript


    I am having trouble getting this script to reset. This script aloows the user to select a region and in turn, the countries below shift in accordance with the region they choose. The problem occurs when the make a selection and go to a new page... if they try to go back to the script, the region resets but the countries do not! I need to figure out how to get the countries to go back to their default. Can anyone help?

    <!--
    var regionsArray = new Array(7);
    regionsArray[0] = new Array("Botswana","Ethiopa","Kenya","Madagascar","Mali","Morocco","Namibia","South Africa","Tanzania","Uganda","Zambia","Zimbabwe");
    regionsArray[1] = new Array("Argentina","Belize","Bolivia","Brazil","Chile","Costa Rica","Galapagos","Panama","Peru");
    regionsArray[2] = new Array("Bhutan","Burma","Cambodia","China","India","Ladakh","Laos","Multi-Country","Nepal","Thailand","Tibet","Vietnam");
    regionsArray[3] = new Array("Greece","Italy","Turkey");
    regionsArray[4] = new Array("Egypt","Iran","Israel","Jordan","Lebanon","Oman","Syria");
    regionsArray[5] = new Array("Australia","Hawaii","Indonesia","New Zealand","Samoa");
    regionsArray[6] = new Array("Antarctic","Arctic")
    function updateCountries(n) {
    var arr = regionsArray[n];
    var current = document.forms[0].countries.options.length;
    for (var j=current;j>0;j--) document.forms[0].countries.options[j] = null;
    for (var i=0;i<arr.length;i++) document.forms[0].countries.options[document.forms[0].countries.options.length] = new Option(arr[i],arr[i]);
    }
    -->
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    New York
    Posts
    122
    Rep Power
    14
    What's the default state for the countries list?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    Chicago, IL
    Posts
    85
    Rep Power
    13

    default


    I want region to default to Africa and the countries to default to the corresponding african countries. Currently, the countries remain on the last region selected so if the user selects americas for example, then goes back, the region will be on africa but the countries will be the american countries.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Posts
    1
    Rep Power
    0
    how about putting

    onLoad("updateCountries(0);")

    in the body tag?
    Last edited by gchip; September 6th, 2001 at 03:29 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    Chicago, IL
    Posts
    85
    Rep Power
    13

    Thumbs down


    That didn't help. Any more clues?

IMN logo majestic logo threadwatch logo seochat tools logo