๐ซณ Auto-Pick the First Option in a Related Event Selector
Ever wanted to automatically register students via a hidden Related Event Selector on a form? For example, students might register for an Admitted Student Day on campus, and you want to automatically register them for various related events.
Itโs easy!
- Place the following into Edit Scripts / Styles on a form.
- Optionally, set your Related Event Selector to hidden.
// Select the first available related event timeslot
$('[data-export="related_event_selector_key"] input')[0].click();
Keep in mind that event communications may be triggered by registering for the related event, even if itโs invisible.
How it Works
- The first portion,
$(
, refers to jQuery, a set of JavaScript tools (framework). - The second portion,
[data-export="related_event_selector_key"]
, locates the group of HTML elements for your related event selector. - Another selector,
input
, finds all HTML input elements (the checkboxes) underneath the previous selectorโs results. [0]
refers to the first checkbox in the array of results.[1]
would refer to the second checkbox. Without this selector, the next step would attempt to select all the checkboxes!.click()
simulates a mouse click on the checkbox.
No Comments