www.webdeveloper.com
Results 1 to 3 of 3

Thread: Problems with selected value dropdown

  1. #1
    Join Date
    Jan 2010
    Posts
    1

    Thumbs up Problems with selected value dropdown

    Hello all,

    I have a problem with a dynamic fill of my dropdown field. I have a dropdown field containing countries, when you select a country a second dropdown will dynamicly be filled with provinces and saved to a mysql databse on submit.

    Now my problem: When you refresh the page, the selected country is the value that you saved in the database (this uses PHP). Only the provinces field is still on the first value of the dynamic list that matches the country.

    Can someone help me with this problem. The database value needs to be the same as the value in the dropdown.

    I hope you can help me! Thanks.

    Code:
    var lists = new Array();
    				
    // First set of text and values
    lists['NL']    = new Array();
    lists['NL'][0] = new Array(
    'Drenthe',
    'Flevoland',
    'Friesland',
    'Gelderland',
    'Groningen',
    'Limburg',
    'Noord-Brabant',
    'Noord-Holland',
    'Overijssel',
    'Utrecht',
    'Zeeland',
    'Zuid-Holland'				
    );
    lists['NL'][1] = new Array(
    'Drenthe',
    'Flevoland',
    'Friesland',
    'Gelderland',
    'Groningen',
    'Limburg',
    'Noord-Brabant',
    'Noord-Holland',
    'Overijssel',
    'Utrecht',
    'Zeeland',
    'Zuid-Holland'	
    );
    
    		
    // Second set of text and values
    lists['BE']    = new Array();
    lists['BE'][0] = new Array(
    'Antwerpen',
    'Brussels (Hoofdstedelijk Gewest)',
    'Henegouwen',
    'Limburg',
    'Luik',
    'Luxemburg',
    'Namen',
    'Oost-Vlaanderen',
    'Vlaams-Brabant',
    'Waals-Brabant',
    'West-Vlaanderen'
    );
    lists['BE'][1] = new Array(
    'Antwerpen',
    'Brussels (Hoofdstedelijk Gewest)',
    'Henegouwen',
    'Limburg',
    'Luik',
    'Luxemburg',
    'Namen',
    'Oost-Vlaanderen',
    'Vlaams-Brabant',
    'Waals-Brabant',
    'West-Vlaanderen'
    );

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Save the value in a cookie that is checked onload.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles