Skip to main content

๐Ÿซณ 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!

  1. Place the following into Edit Scripts / Styles on a form.
  2. 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.