Jump to content

if else based on a drop down menu


leest

Recommended Posts

Ok i am just after some advice, I  have a registration form and want to make a a field only avaliable if the user selects yes from a drop down list.  I also want to make this field a required field.  I think i know how to achieve the last part but was just wondering if any body knew if having a form field display as a result of a drop down menu was possible.

Link to comment
Share on other sites

Something like this:

<form>
<select onChange="if (this.value == 1) text1.style.visibility='visible'; else text1.style.visibility='hidden';">
<option value=0>No</option>
<option value=1>Yes</option>
</select>
<input id="text1" type=TEXT name="text1" style="visibility:hidden">
</form>

Link to comment
Share on other sites

HI thanks for the reply and sorry in the delay but i have been away.  Ok i am not to experienecd with javascript, the field that i want to make only visible if the value in the drop down list is the last field in my form, i have about ten form fields.  so do i change the text1 to represent the field value. 

 

Cheers

Link to comment
Share on other sites

ok, i am a bit of an idiot and when i looked at it properly it made sense, the only thing is when i upload it to my server it didn't work, the drop down list worked but when i selected yes the other field didn't work.  I know i have javascript running on my pc and so not sure why it would not work, could it be something on the server side???

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.