Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>Form auto populate 2nd hidden field

Form auto populate 2nd hidden field

JackLawry
10-14-2005, 01:04 PM
Please be kind its my 1st real post!!!!

Im trying to get a form to post to a php page it is all working but i need it to be easier

eg

<select style="width:100;font-weight : bold" name="city1" tabindex=14>
<option value="Portsmouth">Portsmouth</option>
<option value="Poole">Poole</option>
<option value="Cherbourg">Cherbourg</option>
</select>
<select style="width:100;font-weight : bold" name="countryArr"tabindex=8>
<option value="GBR">UK</option>
<option value="FRA">FRANCE</option>
</select>

but i want it to be just one dropdown eg if you select poole or portsmouth it will automaticly select uk but if you select Cherbourg it will select france and the 2nd dropdown is hidden

any ideas???

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>


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

Form field length
converting check boxes to radio buttons
slashes
onmouseover things
Is their any way of detecting a web site visitors connection speed?
make javascript code more dynamic
View only the main page script?
Possible ?

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics