<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Get the selected option selected on page load"]]></title>
		<link>http://forum.geonames.org/gforum/posts/list/4.page</link>
		<description><![CDATA[Latest messages posted in the topic "Get the selected option selected on page load"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Get the selected option selected on page load</title>
				<description><![CDATA[ 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:
<span class="genmed"><b>Code:</b></span><br>
		<div style="overflow: auto; width: 100%;">
		<pre>    window.onload = function&#40;&#41; {
        &lt;?php 
            if &#40;$_POST&#91;continent&#93;&#41;{ 
                echo 'getplaces&#40;'.$_POST&#91;continent&#93;.',\'country\'&#41;;'."\n";
            }else{ 
                echo 'getplaces&#40;6295630,\'continent\'&#41;;'."\n";
            }
            if &#40;$_POST&#91;country&#93;&#41;{echo 'getplaces&#40;'.$_POST&#91;country&#93;.',\'country\'&#41;;'."\n";}
            if &#40;$_POST&#91;province&#93;&#41;{echo 'getplaces&#40;'.$_POST&#91;province&#93;.',\'province\'&#41;;'."\n";}
            if &#40;$_POST&#91;region&#93;&#41;{echo 'getplaces&#40;'.$_POST&#91;region&#93;.',\'region\'&#41;;'."\n";}
            if &#40;$_POST&#91;city&#93;&#41;{echo 'getplaces&#40;'.$_POST&#91;city&#93;.',\'city\'&#41;;'."\n";}
        ?&gt;
    }</pre>
		</div>

But that did not work ...

I also tried playing with the listPlaces() function like this: 
<span class="genmed"><b>Code:</b></span><br>
		<div style="overflow: auto; width: 100%;">
		<pre>    	for&#40;var i=0;i&lt;counts;i++&#41;{
    		who.options&#91;who.options.length&#93; = new Option&#40;jData.geonames&#91;i&#93;.name,jData.geonames&#91;i&#93;.geonameId&#41;;
            if &#40;jData.geonames&#91;i&#93;.geonameId==whos&#41;{
                who.options&#91;who.options.length&#93;.selected = true;
            }
        }</pre>
		</div>

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!
]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/6070.page#14561</guid>
				<link>http://forum.geonames.org/gforum/posts/list/6070.page#14561</link>
				<pubDate><![CDATA[Wed, 19 Feb 2014 21:08:14]]> GMT</pubDate>
				<author><![CDATA[ webium]]></author>
			</item>
	</channel>
</rss>