Send user to a page based on checkbox field

We have a really simple form with two options: send a user to page A or page B.
If a user chooses checkboxes 1, 3, and 5 then they get page A.
Any other combination selections triggers page B (even if they click 1/3/5, they’d still get page B if they also selected 2 or 4).

I think something like the solution from this discussion will work, but I think what I’m trying to do is much simpler because there’s only two possible actions.

So do something like:

import wixLocation from 'wix-location';
$w.onReady(() => {
$w("#button1").onclick(() => {
const selected = $w("#checkboxGroup1").selectedIndices;
selected.length === 3 && selected.includes(0) && selected.includes(2) && selected.includes(4) ?"/a") :"/b");

Thanks! I can read this a little and I think it’s just verifying that any 3 have been selected? It needs to be specific ones that are checked. Unless “#checkboxGroup1” is something that defines what 3 options need to be checked?

@melindarainsberger No,. It includes 4 conditions:

  1. 3 options (no more no less) are selected AND:

  2. Index 0 (the first option) is selected AND:

  3. Index 2 (the 3rd option) is selected AND:

  4. Index 4 (the 5th option) is selected

@jonatandor35 Thanks! It turns out I needed to do something a little more complete (like the options weren’t that simple). But your explanations were really helpful!