Jump to content

[SOLVED] Using a <select> to show/hide hidden layers


DBookatay

Recommended Posts

I have an application form on my site that requires users to insert information, to apply for credit.

 

I am trying to make a script that shows a hidden layer, named "Previous" if the user selects "01" or "0" from a select box nammed "ap_add5". Which basically means that if the person filling out the form has lived at their current address for less than 2 years a layer showing "Previous Address" fields will appear.

 

Can anyone help with this?

Link to comment
Share on other sites

as "fenway" said, something like this

<script language="javascript">
function show_hide(val){
	if ((val == "0") || (val == "1")) document.getElementById('pre_address_div').style.display = "";
	else document.getElementById('pre_address_div').style.display = "none";
}
</script>
<select onchange="show_hide(this.value);">
<option value="">Select</option>
<option value="0">Less than one year</option>
<option value="1">One Year</option>
<option value="2">Two Years</option>
<option value="3">More than two years</option>
</select>
<div id="pre_address_div" style="display:none;">
Previous address fields
</div>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.