www.webdeveloper.com
Results 1 to 3 of 3

Thread: List of country/state/city in a hierarchy using geonames webservice

  1. #1
    Join Date
    Dec 2008
    Posts
    3

    List of country/state/city in a hierarchy using geonames webservice

    Hey guys!
    I am using a script i found here (http://vikku.info/programming/geodat...-hierarchy.htm)

    It works really nice for what I need to do but I have only one problem. When the client enters data but forget something, the form returns an error and the POST values are inserted in each
    inputs so they don't need to start the whole form. My problem is I can't seem to find a way to auto select the pre-entered data ...

    I made a pastie of my code here
    http://pastie.org/8743532

    So fare, I tried adding the selected option id inside the select tag like this:
    HTML Code:
    <option value="<?=$_POST[continent]?>"></option>
    But that did not work ...

    I also tried playing with the window.onload part by adding more getplaces() like this:
    PHP Code:
        window.onload = function() {
            <?php 
                
    if ($_POST[continent]){ 
                    echo 
    'getplaces('.$_POST[continent].',\'country\');'."\n";
                }else{ 
                    echo 
    'getplaces(6295630,\'continent\');'."\n";
                }
                if (
    $_POST[country]){echo 'getplaces('.$_POST[country].',\'country\');'."\n";}
                if (
    $_POST[province]){echo 'getplaces('.$_POST[province].',\'province\');'."\n";}
                if (
    $_POST[region]){echo 'getplaces('.$_POST[region].',\'region\');'."\n";}
                if (
    $_POST[city]){echo 'getplaces('.$_POST[city].',\'city\');'."\n";}
            
    ?>
        }
    But that did not work ...

    I also tried playing with the listPlaces() function like this:
    HTML Code:
        	for(var i=0;i<counts;i++){
        		who.options[who.options.length] = new Option(jData.geonames[i].name,jData.geonames[i].geonameId);
                if (jData.geonames[i].geonameId==whos){
                    who.options[who.options.length].selected = true;
                }
            }
    But you guessed it right ... it did not work ... I am out of options. I would hate having to change the script ... Any help would be apreciated!

  2. #2
    Join Date
    Dec 2008
    Posts
    3
    Nobody?

  3. #3
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,350
    What does your <form> tag look like?

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