Forum Replies Created

Viewing 1 replies (of 1 total)
  • I used the following code successfully on the page template inside my child theme. The form has a field inquiring “Do you have a guest?” with the radio button for Yes. (I left off No, as the rest of the form was irrelevant if there was no guest.) If the field “guests” is checked the hidden fields are shown.

    As the pdb form is a table, the code below targets specific parts of the table using the :nth-child() selector. You’ll need to figure out which table rows you want to hide and insert the correct numbers in the :nth-child() selectors, and the replace the field guests with whatever your field is called.

    Hope this helps.

    /*IN CHILD THEME HEADER.PHP*/

    <script src="<?php echo get_template_directory_uri(); ?>/jq/jquery-1.11.2.js" type="text/javascript"></script>
    <script src="<?php echo get_template_directory_uri(); ?>/jq/jquery-1.11.2.min.js" type="text/javascript"></script>

    /*ON PAGE TEMPLATE*/

    <script type="text/javascript">
    	jQuery(document).ready(function($) {
    	$(".form-table tr:nth-child(4),.form-table tr:nth-child(5),.form-table tr:nth-child(6)").hide();
    	$("input[name=guests]").click(function()
    		{
    		if ( $("[name=guests]").attr('checked'))
    			$(".form-table tr:nth-child(4),.form-table tr:nth-child(5),.form-table tr:nth-child(6)").show();
    		});
    	});
    </script>
Viewing 1 replies (of 1 total)