bootcom
10-15-2005, 07:08 AM
Sure.
Created a function to split the value of the input (which seperates the country and city names with the "|" character. If the input has no value it skips the function ... if the input has a value it splits the value and shows both seperate values as an alert. This should be straightforward to save directly to hidden form boxes.
Hope this helps !
function auto(val){
var string = new Array();
var country;
var city;
if(val != ""){
string = val.split("|");
country = string[0]
city = string[1]
// I've used an alert here but you could just as easily write to 2 different
// hidden input boxes
alert("The country is: " + country + "\nThe city is " + city)
}
}
<select onChange="auto(this.value)">
<option value=""> Select One </option>
<option value="uk|portsmouth">Portsmouth</option>
<option value="USA|chicago">chicago</option>
</select>
Created a function to split the value of the input (which seperates the country and city names with the "|" character. If the input has no value it skips the function ... if the input has a value it splits the value and shows both seperate values as an alert. This should be straightforward to save directly to hidden form boxes.
Hope this helps !
function auto(val){
var string = new Array();
var country;
var city;
if(val != ""){
string = val.split("|");
country = string[0]
city = string[1]
// I've used an alert here but you could just as easily write to 2 different
// hidden input boxes
alert("The country is: " + country + "\nThe city is " + city)
}
}
<select onChange="auto(this.value)">
<option value=""> Select One </option>
<option value="uk|portsmouth">Portsmouth</option>
<option value="USA|chicago">chicago</option>
</select>
