A 3 part form location selector.

July 2, 2006 by Stephen Williams

Download this file : http://dailybuzz.net/ee/country/city_state.js

then create a standard html page and include this in between the body code. Make sure the 2 pages are in the same location.

<script type="text/javascript" src="city_state.js"></script>
</head>
<body onload="document.getElementById('region').value = 'North America';document.getElementById('region').onchange();">
<div id="widget">
<form>
Region&raquo; <select id='region' onchange="set_country(this,country,city_state)" size="1" name="region">
<option value="" selected="selected">SELECT REGION</option>
<option value=""></option>
<script type="text/javascript">
setRegions(this);
</script>
</select>
Country&raquo; <select name="country" size="1" disabled="disabled" onchange="set_city_state(this,city_state)"></select>
City/State&raquo; <select name="city_state" size="1" disabled="disabled" onchange="print_city_state(country,this)"></select>
</form>
<div id="txtregion"></div>
<div id="txtplacename"></div>
</div>
<script type="text/javascript">
//  document.getElementById('region').value = 'North America';
//  document.getElementById('region').onchange();
</script>

Hopefully if all works you should have 3 fields to select the Location, Country and City.

RE: A 3 part form location selector: 99% working

July 3, 2006 by Toby Wallis

Wow! Thanks, Stephen. After 3 years I'd sort of given up expecting any response to this post... but as it happens it's an issue that has just come round again, so your reply was actually very timely.

I tried it and it's working 99%. There's a test page at http://www.boo-online.com/states.htm. The only problem is that I get JavaScript errors when I select Region or Country. When I select a Region I get:

Line: 304
Char: 2
Error: Object doesn't support this property or method
Code: 0
URL: http://www.boo-online.com/states.htm

When I select a Country I get:

Line: 322
Char: 2
Error: Object doesn't support this property or method
Code: 0
URL: http://www.boo-online.com/states.htm

- although th script actually works fine.

Any suggestions?

Thanks again

===Toby===

Not sure

July 3, 2006 by Stephen Williams

Hmmm, well I actually tested the script using a .php page - have you tried this? also I have'nt used .htm pages but maybe .html pages might fix it?

RE: Not sure

July 3, 2006 by Toby Wallis

Well. I tried it, even though I don't know what difference that might make. Created states.php and states.html. Guess what? The same problem...

 

I think it's a JavaScript issue - could it be anything to do with my browser version (MSIE v6.0.2900)?

Otherwise, maybe it's a scripting problem??

Thanks

===Toby===