Customize Submit button depend on user input form

Dear All,
i’ve client which he want to customize submit button.
there is a form and filling form here below the detail :
name :
address :
number of pax :
submit
when visitor fill the form and fill the number of pax the submit button will change the link button because if visitor choose 1 pax it should go to link url 1. and if visitor fill choose 2 pax the submit button willl go to link url 2.

how to display a submit button with different url depend on user input ?

hope you can help me about this matter. thank you.

Hey
The button has property .link BUT if the button is setup as a submit button for a Data Collection to store data or in some other way has a click action configured by Wix interface and not by code this will not work for you because a button can only have one click event handler.

But if you just want the url to change and redirect the user to different pages depending on values of pax you can use this code.

let paxValue = Number($w("#numberofpaxfieldid").value);
if (paxValue === 1) {
  $w("#buttonid").link = "url 1 here";
  $w("#buttonid").target = "_self"; // same window or new window _blank
} else if (paxValue === 2) {
  $w("#buttonid").link = "url 2 here";
  $w("#buttonid").target = "_self"; // same window or new window _blank
}

You can create 2 buttons where each button is setup with the appropriate link. You can hide one or both buttons when the page is loaded using the hide() function. Then add code to the onChange event for your drop down box so you can control which button is made visible like $w(“#button10)'.hide(); and below that $w(”#button11)'.show();. Obviously this solution is only appropriate with a small number of options, which your example implies. I have used this approach in the past when data only needs to be saved to a child table. The same idea could be accomplished with a check box when there are only two choices.

thank you all. now we have a new problem is there is an error said that
" App with the id - 14ce1214-b278-a7e4-1373-00cebd1 failed to load "
how to fix this error ?
thanks