Changing if statement to a for loop

Hello Guys,

I’d like some help in changing these few lines of code into a for loop

export function button1_click(event, $w) {
if($w(“#input1”).value === “1”) {
$w(‘#button1’).disable();
wixLocation.to(“https://www.google.com”);
}
else {
$w(‘#group1’).hide();
$w(‘#group2’).show();
}
}

export function button2_click(event, $w) {
if($w(“#input2”).value === “2”) {
$w(‘#button2’).disable();
wixLocation.to(“https://www.google.com”);
}
else {
$w(‘#group2’).hide();
$w(‘#group3’).show();
}
}

export function button3_click(event, $w) {
if($w(“#input3”).value === “1”) {
$w(‘#button3’).disable();
wixLocation.to(“https://www.google.com”);
}
else {
$w(‘#group3’).hide();
$w(‘#group4’).show();
}
}

Thanks in advance.

Hi,

The code that you have is all event handlers that handle button clicks. You can’t really put these in a loop - each one exists on its own.

I hope this helps,

Yisrael