Hey guys!
I am using a script i found here (http://vikku.info/programming/geodata/geonames-get-country-state-city-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:
<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:
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:
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!