Error: Provided link type is not supported

I created an algorithme, when user checks checkbox, he should be refered to one page of my site and if checkbox is not checked, he should be refered to another page of my site.
My code is simple

if (typePayement == 'true') {
  $w('#paymentBtn').link = "/one_page";
} else {
  $w('#paymentBtn').link = "/another_page";
}

True of false by checking and unchecking checkbox is working well

But when I click on the button, every time I have an error Provided link is not supported. Even if I put “$w(”#paymentBtn").link=“http://wix.com”; it doesn’t work…
What is wrong??

Compare your generated code with the API-DOCS everything seems to be ok at the first view.


Is it a custom button, or a button from APP or something like that?

my pages have proper names like “one-page” and “seconde-page”

Even I renamed pages like “one” and “two”… but error is the same…

We’ll need more information in order to help. Where do you have this code? When is it run? Post more of your code here in a code block so we can see what you are doing and how.

I found the problem. The button was from the form… That’s why it couldn’t take the link. It’s stupid thing… I added simple button and it works, almost… because I need to click twice, the first click sets the link and seconde one procede the redirection.
I would like that the redirection might be by one click
And I would like as well registre the information from this form.

Sombody has an idea how to solve these two requirements?

Exactly why i asked you the following …:wink:


Try to code a redirection-sequence with → time-delay, after button was clicked…

let timeDelay = 100
setTimeout(()=>{... your code here for redirection...},timeDelay);

You shouldn’t be setting the link when you click the button, that’s why you need two clicks. You should set the link somewhere else, for example, in the Checkbox onChange() event handler. Then when you click the button, it redirects.

You want something like this:

$w.onReady(function () {

   $w("#checkbox1").onChange((event) => {
      let isChecked = $w('#checkbox1').checked;
      if(isChecked === 'true') {  
         $w('#paymentBtn').link = "/one_page";
      }
      else {
         $w('#paymentBtn').link = "/another_page";
      }
   });

});

Note: change #checkbox1 to whatever the name of your Checkbox is.

The above code sets the link of the #paymentBtn whenever the checkbox value changes. Clicking on #paymentBtn will redirect to the page according to the value of the checkbox.

Thank you Yisrael, yes, I attributed initial link to the button and with the function it is changed or not :slight_smile:
Something done :slight_smile: