So I’ve already submitted a feedback/support, but have not received a response. I need to redirect to another page upon successful submission. It is not working
This happens right now:
Button links to Submit
When successful, navigate to: Dynamic Page
(THIS WORKS)
This connection is not the one I need
What I need to happen is this:
Button links to Submit
When successful, navigate to: Link → Regular Page
(THIS DOES NOT WORK)
What happens after submit:
Form saves data in live database
Stays on the same page and does not redirect to Regular Page
What I have attempted:
Deleted button, created new button, connected button (as explained above)
Deleted dataset, connected entire form again
Deleted button, published site, went back to editor to add a new button
Hi,
I’ve tested it on my site and it works fine on my end. In order for us to successfully review this matter further, please send us a video of the issue using screencast . Simply recreate the issue while recording the steps. Add the screencast.com URL to your response. Moreover, please send us the site URL so that we can have a look.
Sorry, I wasn’t clear. It doesnt work on a specific site. It works fine on all my other sites.
If you look in my account, the site is saved as: casties
Thanks! I’ve been absolutely fixated!
Your point is duly noted about the differences with the problems we’re experiencing. I did have the EXACT issue you were having with the submit button on my ‘report a transaction’ page. I ended up fixing it by deleting and then re-adding the related item data set in addition to the database data set if that makes any sense!
More specifically, I was originally using the associated table’s ‘item’ data set on the form page as opposed to the database item set. I misspoke in my first response to you. What I should have said is that I replaced the ‘item’ data set with the database data set. I’m almost positive that’s what fixed my problem with that particular page.
I had both of these issues in my workflow. strangely the buttons seemed to work intermittently. I also tried this: “I replaced the ‘item’ data set with the database data set” to no avail…
Update: VERY QUIRKY. I tried adding a new button, while keeping the old, and renaming everything with the new button number sequence. Updated export button properties and viola! IT WORKED. To note, I tried the same exact thing a NUMBER of times with the original button, checking code, references and the button was still dead. I went through it with a fine tooth comb multiple times.
NOW that I have a working button, it seems to sometimes load on the page and sometimes not. If I refresh the page a few times it will load but without rhyme or reason. How do I report that? Button actions need to be dependable! I can hear the calls now… anyway, clunky progress made… i think?
Hi,
Was just looking through the pages for an issue that I am having that is similiar to this. I will add my experience.
I have a button which I want it to do two things. Firstly have an onclick action, then also redirect to a “Thank you” Page.
The button i have currently works fine with the onclick event, but does not redirect to the new page.
I did some testing and the redirect worked, if I removed the onclick event.
So not sure if this is the same as you experience, or if this is a bug, but basically having a button with a redirect does not work if there is also an event associated with the button.
Yes, you are right. When you have an onClick() event handler, the redirect then won’t work. What you can do is to put the redirect into your onClick() code using wix-location.to().
For example:
import wixLocation from 'wix-location';
export function button_click(event, $w) {
// ... your onClick stuff here
wixLocation.to("/otherpage");
}
Just wanted to chime in here… Somehow I figured out pretty quickly how to redirect to a thank you page by clicking the Submit button. I understand that some above were trying to do more than one thing (redirect to thank you page), but just in case - I am showing here what needs to be done:
Notice that the links location is hiding at the bottom. You need to grab the bar and scroll down. There you can choose a page location or insert a link… It worked perfect for me.
Thanks Naama … but those are all set. So far I have only had the issue on 3 sites now in total. All others work well.
One of those sites was a brand new site with zero previous code and the button redirect (regular link) still didn’t work. But again, as soon as I change it from regular link to a dynamic page … the redirect works fine.
Hi @Nayeli I figured you had a local issue. Somehow I felt I should have added my post in case anyone will look for the answer, regardless of the bug. That’s super wired and I will remember you tip in case it happens to me in the future. Have fun in Miami !
Very helpful thread, thanks. I am hoping for a bit more guidance on the solution.
This is what I am trying to do:
A user fills out a form with multiple inputs (e.g. some radio buttons, some text boxes, etc).
The responses are submitted to a database
The responses are also emailed to me
After submitting, the user is redirected to another page.
I have successfully programmed the first three steps above by referring to Nayeli’s very useful video here ( www.youtube.com/watch?v=LdKUYMN9w6E ).
However, I am struggling with the redirect on the submit button. As noted above, the usual way of redirecting on submit doesn’t work in this circumstance. Ysrael provided a solution but, being a novice coder, I’m not sure how it works in my situation. The submit button is #button1. I have tried to include Ysrael’s suggested code but without success. How should the code below be fixed?
import {sendEmail, sendEmailWithRecipient} from ‘backend/email1’;
import wixLocation from ‘wix-location’;
function sendFormData() {
const subject = This email contains responses from our website;
const body = Here are the responses: \rresponse1 ${$w("#radioGroup1").value} \rresponse2 ${$w("#checkbox1").checked} \rresponse3 ${$w("#dropdown1").value} \rresponse4 ${$w("#input1").value};
const recipient = $w(“#input8”).value;
sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));
sendEmail(subject, body)
.then(response => console.log(response));
}
$w(“#button1”).onClick( (event, $w) => {
wixLocation.to(“/pageiwanttoredirectusersto”)
} );
The code you wrote above is only partial code to what you actually have on the page. Find the part of the code that says ‘after save’ … it is in that block of code where you will add the single line that says ‘wixLocation’ …
This means you are telling the code … “After the dataset saves, please send email and please redirect to this other page”