Aus2Srq
asked on
Javascript/CSS: form fields based on country drop down
I need to change my address form to have fields based on being domestic (US) or international (outside US). The 4 fields that will change will be Address 1, Address 2, City, State to Address 1, Address 2, Address 3, Address 4 (these will be the fields for Town & County in UK, Village & City in Japan or District & Province in China). My thoughts for the form are as such:
First Name:<input type="text" name="f_name""><br>
Last Name:<input type="text" name="l_name""><br>
Country:<select name="country"><br>
<option value="US">United States</option>
<option value="AU">Australia</opti on>
<option value="JP">Japan</option>
...
</select>
<!-- show if country is USA //-->
Address 1:<input type="text" name="add_1"><br>
Address 2:<input type="text" name="add_2"><br>
City :<input type="text" name="geo_1"><br>
State:<select name="geo_2"><br>
<option value="AL">Alabama</option >
<option value="AK">Alaska</option>
<option value="AZ>Arizona</option>
...
</select>
<!-- show if country outside USA /-->
Address 1:<input type="text" name="add_1"><br>
Address 2:<input type="text" name="add_2"><br>
Address 3:<input type="text" name="geo_1"><br>
Address 4:<input type="text" name="geo_2"><br>
The easiest to place into the existing code is if the drop down called a script that used CSS to hide and unhide the form elements.
Thanks!
~A2S
First Name:<input type="text" name="f_name""><br>
Last Name:<input type="text" name="l_name""><br>
Country:<select name="country"><br>
<option value="US">United States</option>
<option value="AU">Australia</opti
<option value="JP">Japan</option>
...
</select>
<!-- show if country is USA //-->
Address 1:<input type="text" name="add_1"><br>
Address 2:<input type="text" name="add_2"><br>
City :<input type="text" name="geo_1"><br>
State:<select name="geo_2"><br>
<option value="AL">Alabama</option
<option value="AK">Alaska</option>
<option value="AZ>Arizona</option>
...
</select>
<!-- show if country outside USA /-->
Address 1:<input type="text" name="add_1"><br>
Address 2:<input type="text" name="add_2"><br>
Address 3:<input type="text" name="geo_1"><br>
Address 4:<input type="text" name="geo_2"><br>
The easiest to place into the existing code is if the drop down called a script that used CSS to hide and unhide the form elements.
Thanks!
~A2S
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is a very little typo in the code. Change
<option value="AZ>Arizona</option>
to
<option value="AZ">Arizona</option >
<option value="AZ>Arizona</option>
to
<option value="AZ">Arizona</option
Any reason for the "B" grade other than that I am in timezone CET and therefore did not reply immediately?
ASKER
document.getElementById("n
Any ideas?
A2S