This has to be done using javascript, not terribly difficult if you are familiar with jQuery. You can put your script into a custom plugin template.
I am not very familiar with jQuery but I can certainly understand and follow instructions on how to work with jQuery and javascript. Do you have any instructions or any other link to a solution that someone else has done for your plugin?
Hope you consider this for an update because this plugin is very good.
Please let me know how you can help me with this.
Thank you!
I suggest you do a web search for something like: “jquery conditional hide form input” you’ll find lots of examples of how to do this. That’s what I would do.
Take a look at this article that explains how to use custom plugin templates:
How to Create Custom Templates
Thanks for the info.
I have tried a few solutions but none seems to work. Not sure what I am doing wrong.
I added jQuery files to my root in a folder and then added the following code to my head:
<script src=”/jq/jquery-1.11.2.js”></script>
<script src=”/jq/jquery-1.11.2.min.js”></script>
<script>
$(‘input[name=”subscribe”]’).on(‘click’, function(){
if ( $(this).is(‘:checked’) ) {
$(‘input[name=”email”]’).show();
}
else {
$(‘input[name=”email”]’).hide();
}
});
</script>
I also tried adding it on top of pdb-signup-default.php and copied it in my child theme’s template folder.
Still no luck.
Any idea?
Thanks
I don’t know, but to start with, you can’t use “$” as an alias for jQuery in the WordPress environment. either replace the “$” with jQuery” or use no-conflict mode.
Try it in Firefox, use the developer tools, they will help a lot.
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>