Conditional redirect on form submit

With project NodeJS
After the success of a submit of a form, I would like to be able to redirect to two different pages depending on the value of a field of the form
It’s possible?

if fieldXXX = “1” browser1.goto('page1')"
… ???
if fieldXXX = “2” browser1.goto('page2')"

Yes. Use a set value to the $POST’d field, makes sure it’s output is checked, then in the onsuccess event of the form, add your check and browser redirect

Thank you
I’m spinning around but I can’t finish
in the page I have a radio field with two alternative choices. The field is saved correctly in the database with the value corresponding to the choice made.
In my case the “circuit” field saves “stripe” or paypal "
If the form submission is successful I can only insert a single “go to” action
I cannot set a condition that allows me to direct to two different pages depending on the choice made

The redirect logic goes into the frm_new_payment onsuccess event.

OK But that's what I can't do

You could use an inline flow on the success event of the form, then in the flow you can have a condition that checks the param where ever it comes from, after that use the run step in each of the then or else sections provided by the condition

Your logic needs to be added to the frm_new_payment DYNAMIC EVENT Success action.

A basic ternary operator.

Browser1.goto(value == ‘stripe’ ? ‘/stripe_url’ : ‘/other_url’)

1 Like

Yes as sorry_duh says use a flow and set a condition

followed by Run to set the briowser1 actions

or you can use a ternary operator

Syntax like this:
radio.value = “stripe” ? browser.goto(‘page1’) : browser1.goto(‘page2’)

1 Like

Thank you all
I looked for the simplest way proposed by iperbyte but I think I did something wrong
I’ll try again, also for the flow suggestion

Schermata 2022-06-04 alle 19.27.42

OK, i see what you are doing. You need to return the value of ther radio button from server action (use a set value stage) so you condition will something like
frm_new_payment.data.nameofsetvalue (you should see it in the picker)

Dont forget to tick output on the set value.

1 Like

Another thing to check - make sure your code doesn’t include any ‘curly’ quotes:

image

1 Like

@Iperbyte
i'm trying your suggestion but i can't understand
If I insert the "form success" statements manually in the code they don't work
If, on the other hand, I want to insert the instructions from the Wappler panel, I can't find the value of the radio "circuit".
I want to clarify that the value of the "circuit" field in the newly created record is correct
How can I recover that value?

Marzio, all you need a simple ternary operator which checks which of your radio controls is checked …

dmx-on:success="browser1.goto(stripe.checked ? 'stripe_checkout' : 'paypal_checkout')

You can also do this using a flow and a condition checking the same condition.

1 Like

Great Teodor !!
I went around in circles but kept making the wrong setting
Now it works perfectly
Thank you very much