Logic on Multi State Box

I am trying to create some logic that will screen the user and redirect him to an application page if the user qualifies.

Can someone help with the code ?
Here is what I wrote:
$w . onReady ( function () {
// Write your JavaScript here

$w ( “#btnAgeYes” ). onClick (( event ) => {
$w ( “#stEligible” ). changeState ( “Bank” );
}
);
$w ( “#btnAgeNo” ). onClick (() => {
$w ( “#stEligible” ). changeState ( “Bank” );
}
);
$w ( “#btnBankYes” ). onClick (() => {
$w ( “#stEligible” ). changeState ( “B2B” );
}
);
$w ( “#btnBankNo” ). onClick (() => {
$w ( “#stEligible” ). changeState ( “B2B” );
}
);
$w ( “#btnB2bYes” ). onClick (() => {
if ( $w ( ‘#btnAgeYes’ ). label === “Yes” && $w ( ‘#btnBankYes’ ). label === “Yes” )
{ wixLocation . to ( “/application” )}
else { wixLocation . to ( “/donotqualify” )}

Take this example for guiding reference. It is a very old one, but should still work for your purposes.

https://russian-dima.wixsite.com/meinewebsite/little-quiz

1 Like