View Full Version : posting variables into fields using radio buttons...

03-12-2004, 09:59 PM
Hey there, this will be easy for most of you...

my site has a city selection with radio buttons. When I click on a radio button I need to input the city name into a designated text field and input the appropriate state abbreviation into a pulldown menu next to it.

Right now the City works perfect, how can I now change the state as well with it?

the code to define the cities (which I got here) :) :


var city = new Array();

city["Atlanta"] = ["Atlanta",""];

city["Boston"] = ["Boston",""];

city["Chicago"] = ["Chicago",""];

city["Dallas"] = ["Dallas",""];

city["Denver"] = ["Denver",""];

city["Hawaii"] = ["Hawaii",""];

city["Las Vegas"] = ["Las Vegas",""];

city["London"] = ["London",""];

city["Los Angeles"] = ["Los Angeles",""];

city["Miami"] = ["Miami",""];

city["New Orleans"] = ["New Orleans",""];

city["New York"] = ["New York",""];

city["Orlando"] = ["Orlando",""];

city["Paris"] = ["Paris",""];

city["Phoenix"] = ["Phoenix",""];

city["San Diego"] = ["San Diego",""];

city["San Francisco"] = ["San Francisco",""];

city["San Jose"] = ["San Jose",""];

city["Seattle"] = ["Seattle",""];

city["Washington"] = ["Washington",""];

function setCode(theRadio){

theForm = theRadio.form;


the following is a sample of one radio button:

<label for="Los Angeles"><INPUT type="radio" name="searchShortCityName" value="Los Angeles"
onclick="setCode(this)" id="Los Angeles">Los Angeles</label>

And my pulldown menu looks the following:

<select name=state id="select2" size=1 class=content-sm>

<option value="">

<option value= "AK">AK - Alaska</option>

<option value="AL">AL - Alabama</option> <option value="AR">AR - Arkansas</option>

03-12-2004, 10:18 PM
http://www.travelgrove.com/travel_grove.php I got the tables all screwed up now and for some reason my script doesn't plug the values in anymore?! weird...

if you go to http://www.travelgrove.com/travel_grove.php?site=2 the hotel search box works just fine.

If you would like to comment about the site (obviously under construction only) then go ahead... There is tons of stuff that needs to get done, but I am slowly getting there, with the help of the javascript forum.