Problem with submit not switching pages

I’m having a show stopper issue with a form not switching over to another page after a successful dataset submission. Oh yeah, it works just fine in preview mode. The button saves the data, and switches to the other page.

This happens both with a button with a submit action, or with code linked to a click event.

ie:

$w(“#dataset1”).save()
.then( (item) => {
wixLocation.to(“/myreservations”);
} )
.catch( (err) => {
let errMsg = err;
changetext(“#text64”,“Missing fields.”);
} );

Whatever actions I put in here work, such as changing a text message for example, but the wixLocation does nothing. Strangely, when looking at the live console, it does say that the myreservations.js code gets loaded, but it never leaves the form page.

Am I missing something? This is keeping me from taking the page live.

Can you share a link to your page?

Hi All / @ofer-wix (Wix),

I’m trying to use " User input " ’ Switch ’ to toggle between two websites… a very simple implementation.
There is going to be 2 different language websites (identical).

When user switch it on to ‘right’ it will redirect to English website and when it is turned off “left” it should go to the language website.

I’m not a coder but have done some basic implementations:
Can someone tell me what exactly I need to do… with code that I can use.

Thanks in advance,
Pawan

Hi Pawan,
Some code is required.
My suggestion is to change the text to the relevant language my using text key of $w and not redirect to a different website.
Moreover, I would use onChange event for the switch element so it should look something like this:

export function switch1_change(event) {
    if (event.target.checked) {
        $w('#myTextElement').text = 'Text in english';
    } else {
        $w('#myTextElement').text = 'Text in other language';
    }
}

Good luck!
Roi.

Thanks for your revert.
But there is going to be 2 different websites I need to link with this switch.
FYI: Main EN site is live and the language sites are almost ready.
Only way for me to redirect it via switch.

I tried my hands with below code but I’ know its completely wrong.

I’m very new to code and learning ABC of it, would be great help if you can put the code here… please :pray:t3:

import wixLocation from 'wix-location';
$w.onReady(function () {
if (wixLocation.to('https://www.mezonic.com')) {
    $w('#switch1').checked = true }

else {
    $w('#switch1').checked = false }});

Thanks,
Pawan

@pawan

export function switch1_change(event) {
    if (event.target.checked) {
        wixLocation.to('https://www.mezonic.com')
    } else {
        wixLocation.to('https://www.otherSite.com')
    }
}

Make sure to set the switch to right mode and to add the onChange event.
Good luck!
Roi.

@roi-bendet

I tried but its not working. PFB screenshot kindly guide me what I’m doing wrong here:


Thanks,
Pawan