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



Show first post

142 replies

Userlevel 6

Thanks for requesting this @stefanei! I put together a version of the script that will allow you to choose the number of fields to reveal. Change the number after “var count =” to the number of fields you need to conditionally hide. It ill work the same way in that it will apply to the fields immediately following the dropdown.
You can grab the updated script here - https://gist.github.com/RobertCam/0be9efb09a091e1880ffeb5edadf2d1a

The number for the space variable will slightly adjust the spacing of the visible fields after the dropdown (if there are any). I’ve defaulted it all to work with 5 fields. But if you change the number you may need to play around with the space variable a bit to get it perfectly placed.

@ltaylor You can definitely have fields that are always visible after the conditionally displayed field. Here’s an example: http://unbouncepages.com/conditional-dropdown-multiple-fields/

🙂

This is great! Is it possible to have only the next field display (or not), but then have fields afterward that always display or does this only work when the fields are at the end of the form? I’m not much of a coder so any guidance or tips would be so appreciated! 🙂

Thank you! If the script could work with 5 fields at this point that would be great!

Userlevel 6

Thanks @stefanei! How many fields do you need this to work with? It’s for sure possible but requires a bit of reworking the script how it’s currently written. I’m working on making it more dynamic, but I can help you out with this one in the meantime.

Just tried out this script today, really nice work! I too would be interested in having more than two fields if possible

We push to the limit! Thanks for support @Rob !

Rob, you da real MVP.

Userlevel 7
Badge +1

You’re a ⭐ Rob!

Userlevel 6

If anyone is interested, thanks to @Daniele_Madia_Privat’s question, I’ve adapted the script to work with more than 2 fields. Shoot me a message if you’d like to conditionally display more than two fields with the script.

Userlevel 6

@Daniele_Madia_Privat Feel free to direct message me and include the page URL and I can take a look for you 🙂

I’m trying with no sucess to integrate conditional display with Dynamic Form Confirmation URL’s Using Browser Redirects. For example my goal is a form with “select state/country” -> after selection appear the form with all city of selected country -> selection city with redirect to a specific url.com/city. Anyone have an idea how to do that?

Userlevel 6

Looks like you got this figured out already @Daniele_Madia_Privat 🙂

For anyone else reading this, you can easily use this multiple times by copy/pasting the javascript and changing the ID to match the new dropdown and the submit button.

Ok done with 4 options

It’s possible to use it for more than 2 option?

Userlevel 6
Badge +1

Oh man sooooo nice … sooooo useful!!! LOVE IT. 😍

This. Is. Awesome! Love this basic form logic functionality, @Rob. 🙂

Userlevel 7
Badge +1

@Rob this is hot fire!!! 🔥

Reply