Is there a way to have my “State” drop-down menu only show when the US is selected? Same goes for Canada?
Hey edang
This is possible but it may require a bit of conditional code depending on how many fields you are showing/hiding. There also may be some visual side effects.
One being that the other elements/fields on the page do not re-adjust or re-align when an element is hidden. This is because elements on your pages are not relatively positioned, but are positioned with exact coordinates.
I don’t have a plug and play script for you, but if you want to try whipping something up yourself, here’s a script to guide you in the right direction.
<script>
$("#country").live('change', function() {
switch ($(this).val()) {
case 'United States':
// Add code here to show and hide fields
break;
case 'Canada':
// Add code here to show and hide fields
break;
default:
// Add code here to hide all fields
}
});
</script>
I’d suggest looking into jQuerys .hide and .show methods for actually hiding/showing the fields
http://api.jquery.com/hide/
http://api.jquery.com/show/
Hope that helps!
Anyway of getting the content from this old forum? Conditional Forms (aka Form Logic)
Sorry for the late reply. Looks like this was used on a page that is no longer active. I’m going to attempt to locate the files and (hopefully) get you the script by end of day.
Sorry for the delay!
@Stefano were you able to find anything?
@edang you should be able to do this with some conditional CSS. Let me see if I can dig up some old code for you!
Hey @edang, is this for a form?
Reply
Log in to the Unbounce Community
No account yet? Create an account
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.