The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Hide Dropdown field options base on selection in another dropdown
Hi I have 2 dropdown fields,
States [211] lists the US states
Deductibles [210] lists 5 deductibles, values are i.e. FIC - 0.002 .
I'm trying to hide the deductibles based on the state you select.
If you select MI as the state I need deductible 1, 2 & 3 hidden
If you select any other state I need deductible 4 & 5 hidden
I'm tying to use this script in the 'After Fields' bit to do it, which I've cobbled together from other scripts that work, but this doesn't 🙁 probably because I've no idea what I'm doing. I would also like to use it in a repeater section, if that makes a difference, it's not in a repeater at the moment, but that's the goal.
If anyone can help it would be much appreciated
<script type="text/javascript"> //Hides deductibles if not available jQuery(document).ready(function($){ $('select[name="item_meta[211]"]').change(function(){ var val1 = $("select[name='item_meta[211]']").val(); if (val1 == 'MI - 0.00943') jQuery("select[name='item_meta[210]']").children('option[value="SWBC - 0.0"]').css('display','none'); jQuery("select[name='item_meta[210]']").children('option[value="FIC - 0.0"]').css('display','none'); jQuery("select[name='item_meta[210]']").children('option[value="Seattle - 0.002"]').css('display','none'); else if (val1 !== 'MI - 0.00943') jQuery("select[name='item_meta[210]']").children('option[value="Seattle - 0.0"]').css('display','none'); jQuery("select[name='item_meta[210]']").children('option[value="FIC - .003"]').css('display','none'); }); }); </script>
February 23, 2019 at 9:19 pm
Howard,
I've refactored your code and tested it on the sample form you emailed to me. Here's the paste where you can retrieve it: https://pastebin.com/kQpmvzqB
May 4, 2019 at 9:00 am
Delete
[…] example of why this is needful is posted by Howard Jennings through the Formidable Community Forum. Mr. Jennings asked how he could hide certain dropdown options based on the value selected in another […]
September 4, 2019 at 10:00 pm
Delete
[…] example of why this is needful is posted by Howard Jennings through the Formidable Community Forum. Mr. Jennings asked how he could hide certain dropdown options based on the value selected in another […]
Discussion closed.