[How to] Conditionally Display Additional Form Fields Based On Dropdown Selection



Show first post

142 replies

I would like to do the same thing. Did you ever figure this out?

Badge

Hi, I am looking for a similar functionality,

I need a form which when a checkbox is checked it shows an additional phone number field. Is there an existing script for this?

Hello everyone! I have a doubt on how to make this happen:

Basically, I want to:

  • When Dropdown = 0, no fields are shown and the submit button becomes just a link to a specific page.
  • If dropdown = 1 I ask for the email
  • If dropdown = 2, I ask for email and phone

Right now, the scripts I’m using are:

But this is not allowing me to show 2 fields (email and phone) when dropdown is 2.

Thanks

Hey @Carin Did you manage to do this? I’m looking for the same thing

I ended up doing something more “manual” and less pretty, but it works.

Hope somebody can answer my questions so I can make it better.

Userlevel 7
Badge +3

Hi @Alfonsosbla,

You’ll need some custom JS and CSS to get the form working as you want.

The actual JS/CSS would have to be written specifically for your use case since you’ll have to adjust the position of the fields depending on your exact form. The JS would dictate the logic of what fields are shown when and based off of that the CSS would position the actual fields where they need to go.

On top of that you’ll have to play around with the fields validation and turn it on and off depending on what state the form is currently at. I posted a brief snippet above in regards to the validation.

Best,
Hristian

Hi Gary,
Did you ever figure this out?

Hello,

Thank you very much for the script. Im new here, I have no knowledge in doing jscript, I copied the script that was given but I cant seem to make it work with the below conditions, may I ask for help for the script on this one please:

  • When I select US, it should show City, State, Postcode fields.
  • Else, it hides city, state, postcode fields.

Thank you for the help!

Hello,

Thank you very much for the script. Im new here, I have no knowledge in doing jscript, I copied the script that was given but I cant seem to make it work with the below conditions, may I ask for help for the script on this one please:

  • When I select US, it should show City, State, Postcode fields.
  • Else, it hides city, state, postcode fields.

Thank you for the help!

Opps, I just read one reply with the same condition. Im checking the provided solution. Im all good thank yoU!

Hi Rob,

I have implemented conditional form here on a lightbox "http://preference.lookyounger.net/look-younger/"

Now its not letting me submit the form, basically submit btn is not working :(.

Thanks

Badge

Hello ! 

I've just tested this script on my landing page, everything works perfectly, except that it's impossible to submit the form. When you click on the submit button, nothing happens... 
Could you help me? 

Thanks a lot, 
Perrine

I’m also having an issue with this solution. Everything is working except upon submit of form, nothing happens. Any suggestions on what could be wrong?

Userlevel 7
Badge +3

Hi @Perrine & @Timf

It might be a number of reasons… is the console throwing up any errors? 

Can you duplicate your pages on the unboucepages.com domain and share a link here so the community can try and troubleshoot it for you?


 

Badge

Hi @Hristian 

Thanks for your feedback. 

Here's the link to my test page with the form: http://unbouncepages.com/test-atawa/

Thanks for your help! 

Perrine

@Hristian & @Perrine 

 

I figured it out… at least with my use case. I’m using dropdown selectors for conditionally displaying options. Apparently drop-down selectors appear as required by default if the option“first menu choice is not a valid value” is checked. This also applies to conditionally displayed dropdowns causing these fields to be required and causing form submission not to work. Since the form builder doesn’t have a required checkbox to enable/disable for dropdown selectors, I read on another thread to simply uncheck the option “first menu choice is not a valid value.” So apparently this change makes the dropdowns not required. The logic for this kind of makes sense but ideally I’d like to have the main dropdown required and still have instructional text as first option that is not selectable. 

Badge

hello @Timf 

You're right, I've just tested without the "first menu choice is not a valid value" option and my form sends correctly! Like you, it's quite important for me to be able to keep this functionality. 
Do you think there is a solution @Hristian

Thanks :) 

Userlevel 7
Badge +3

Hi @Perrine

It should be possible to adjust the JS and “play” around with what’s required and what not at a particular state - if the field is visible or if it isn’t visible. 

I don’t have a ready made script but based on my experience with these Unbounce forms, it should be possible.  

Reply