Using jQuery to show and hide form elements by user choices
Sometimes, you may want to expose form elements depending on what previous choices a user has made. For example, you might run a conference over two days. If people only want to attend one day, you will only want to show them further options for that day.
How to do it…
This recipe shows you how to gain control of your event registration forms using jQuery.
Set up a pricelist for your event. Navigate to Administer | CiviContribute | New Price sets and create a new set.
In the new set, create a checkbox field so users can choose what days they want to attend:
Provide two choices: Monday and Tuesday.
Make the Amount column for each choice to be free.
Uncheck Display Amount. This presents the user with two checkboxes with no price display.
Add another checkbox field for further choices for Monday, to be used if the user selects Monday in the first field.
Provide the Lunch and Dinner options for Monday.
Repeat this for Tuesday.
Create an event...