dynamic page onAfterSave

I have a request for quote page that when completed displays a dynamic page with the quote.
PROBLEM: The wix form redirects to the dynamic page if form is completer and even though required fields are not complete when the user presses submit button.

Here is the function to go to dynamic page:

export function goToQuote() {
let value = local.getItem( “gotoURL” )
$w( ‘#message’ ).show( ‘slide’ )
setTimeout( function () {
wixLocation.to(value);
}, 5000 );

}

Here is the on click:

export function submitButton_click(event) {
//Add your code for this event here:
$w( ‘#newQuotesData’ ).onAfterSave(goToQuote())
}

Hello Mark Hancock,

sorry for my bad english, but as i did not understand your problem properly i would to ask you one more time, what is the real problem?

I understood like this:
You have a submission-form. By pressing on the Submission-Button a message appers for 5 secs. before a redirection to a specific URL follows, right?

And your problem is now, that this happens even if the form is not complete, did i understand it right?

Your English is very good, no need to apologize. I’m just trying to redirect to a dynamic page after the form is complete. I have tried every way I can think of. It either does not work at all or it redirects even though the form is not complete if the submit button is pressed. Just looking for a solution.

Thanks for your attention to this matter.

Regards,
Mark

Hello one more time Mark Hancock

sorry i was very busy, because of that my late answer to you.

And here we go, i think you need something like this one…

import wixLocation from 'wix-location';
import wixData from 'wix-data';

var myValue1
var myValue2
var myValue3

$w.onReady(function () { 
 
});


export function button1_click(event) {
    myValue1 =      $w('#input1').value
    myValue2 =      $w('#input2').value
    myValue3 =      $w('#input3').value   
 

    console.log("You clicked on the SUBMIT-BUTTON, the new DATA will be saved now!")
    $w('#dataset1').onReady(()=>{
        $w('#dataset1').setFieldValue("name"    ,   myValue1)
        $w('#dataset1').setFieldValue("lastName",   myValue1)
        $w('#dataset1').setFieldValue("eMail"   ,   myValue1)
    })
    $w("#dataset1").save()
}

export function dataset1_afterSave() {
 if (myValue1!=0 && myValue2!=0 && myValue3!=0) {
        console.log("Submission complete here!")
        myFunctionAfterSave()
    }
 else{
        console.log("Submission incomplete here!")
    }
}


function myFunctionAfterSave (parameter) {
    console.log("AfterSave-Event started")
    $w("#BOX1").show()
    console.log(wixLocation.url)
    $w("#TXT2").text = "Corvid-Forum"
    setTimeout(()=>{$w("#TXT3").text = "3"},1000)
    setTimeout(()=>{$w("#TXT3").text = "2"},2000)
    setTimeout(()=>{$w("#TXT3").text = "1"},3000)
    setTimeout(()=>{wixLocation.to("https://www.wix.com/corvid/forum")},4000)
}

Need an example 4 this code?

Look here…
https://russian-dima.wixsite.com/wixworld/redirection


If the submission is complete, then you will be redirected.
If the submission is incomplete, nothing happens.

Thanks, but I am pretty persistent. I found a solution with much less code. I check if the success message isVisible(). I did have to timeout to give message time to be recognized as visible.

Works great.

export function submitButton_click(event) {
//Add your code for this event here:
$w( ‘#newQuotesData’ ).save()
setTimeout( function () {
if ($w( ‘#successMessage’ ).isVisible) {
goToQuote()
}
}, 2500 );

}

export function goToQuote() {
let value = local.getItem( “gotoURL” )
wixLocation.to(value);
}