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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2004
    Posts
    145
    Thanks
    0
    Thanked 0 Times in 0 Posts

    loading <select> options based on previous <select> choice

    --------------------------------------------------------------------------------

    Hi, I am quite rusty with javascript as I dont use it that often so i need a little guidance!!

    I need to load the contents of a drop down menu but the contents are to be dependant on the selection of a previous drop down menu. It is of the form country-region-town. The values are stored in a database each with associated id's and foreign keys but i thought it was best to retrieve all items and then use javascript to load the appropriate contents, its just that I dont know how!!

    I thought i'd ask as i imagine its something that developers come across every now and then. If ive got the wrong end of the stick and it is a php question let me know and I will post tin the other forum.

    Thanks.

  • #2
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Hi,

    see the cascading selects scripts/explanations at : http://members.aol.com/grassblad

    also, dynamicdrive has one or two scripts w/o explanation

    Vinny
    Where the world once stood
    the blades of grass
    cut me still

  • #3
    Regular Coder
    Join Date
    Feb 2004
    Posts
    145
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, thats a big help but im retrieving all my data from a mysql database and hence my arrays will be php arrays rather than javascript arrays, im a bit stuck on how to approach this!

  • #4
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    <?
    $connect = odbc_connect($db, $user, $pass) or die ($error);
    $query = "SELECT * FROM TABLE";
    $result = odbc_exec($connect, $query);

    while(odbc_fetch_row($result))
    $arrDef[] = '"'.$result.'"';

    odbc_close($connect);

    $strJsArr = implode(',', $arrDef);

    echo 'var arr = ['.$strJsArr."]\n";
    ?>
    Where the world once stood
    the blades of grass
    cut me still


  •  

    Posting Permissions

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