I have a Wix Code user input form. I really want to display a page, after the user has submitted the form, that is different, depending on the user’s input. That is - I have a radio button set, and I want to display a different “Thank You” page, depending on the option chosen. I don’t really care if this is done in a separate page, or, alternatively, by expanding a specific strip and collapsing all others in one page (which could even be the same page as the form itself.)
Any suggestions?
Hi,
It really depends which way you choose.
The simple one would be to show on the same page.
Let’s say you have radio buttons name ‘#radioButtons1’ and a button name ‘#button1’, and a collection called ‘userInput’.
For the thank you message - ‘#text1’;
Instead of setting the button to be ‘Submit’, just create an onClick() function for it, save the data to the collection yourself , and show the message:
export function button1_click(event) {
const userInput = $w('#radioButtons1').value;
wixData.insert('userInput', {userInput: userInput});
$w('#text1').text = `Thanks for choosing ${userInput}`;
// Show/expand #text1 and hide/collapse other
}
Hope this helps,
Liran.
Oh, cool. Does that mean I don’t link the button to the dataset and to submit, but rather - I have to do the submission programmatically, through the code?
OK. I tried it a bit and I realize I don’t have to do the submission manually. Great! Thanks!
But then there’s the problem of actually collapsing and expanding the strips: I don’t want to do it in the “click” function, because I want it to happen only when the submission was successful. I tried using the dataset’s afterSave, but for some reason I then get an error saying that w isn’t a function (I tried the same line of code in other places in the code, and it works fine. The fact that it’s in this location in the code definitely has something to do with the fact that the error occurs).