Goodmorning, is there a way to create this type of form?
input // a variable like a number or a text
on submit
if (input == case1)
url redirect : www.....
else
if (input == case2)
url redirect2 : www...
else
if (input == case3)
....
Hi ratne,
Yes, use a Custom Code action in the On Submit event with code like this:
Yes, use a Custom Code action in the On Submit event with code like this:
<?php
switch ( $form->data['input'] ) {
case 'case1':
$form->data['redirect_url'] = 'www.. . .';
break;
case 'case2':
$form->data['redirect_url'] = 'www.. . .';
break;
case 'case3':
$form->data['redirect_url'] = 'www.. . .';
break;
}
?>
And add a Redirect User action as the last action in the On Submit event.
i've donw this but it does not work.
Second question. How can i insert an error message if the word did not match?
Second question. How can i insert an error message if the word did not match?
Hi Ratne,
Sorry, I copied part of that code and it was incorrect. I've updated my post. Here's the working version
You also need to add the ReDirect User action with a blank Target URL box.
To show an error if there is no match I would use the Serverside validation action.
Bob
Sorry, I copied part of that code and it was incorrect. I've updated my post. Here's the working version
<?php
switch ( $form->data['data'] ) {
case 'case1':
$form->data['redirect_url'] = 'http://www.davideiacomi.info';
break;
case 'case2':
$form->data['redirect_url'] = 'http://www.pampaninirossi.it';
break;
case 'case3':
$form->data['redirect_url'] = 'http://www.pampaninirossi.com';
break;
}
?>
Note that I've added the http:// to the URLs and changed the $form->data['data'] to match the name of your form input.You also need to add the ReDirect User action with a blank Target URL box.
To show an error if there is no match I would use the Serverside validation action.
Bob
Ok it finally work, now i've only to know what you mean for this
and the form is ready.
Thank you very much!
To show an error if there is no match I would use the Serverside validation action.
and the form is ready.
Thank you very much!
Hi Ratne,
If you really only allow a limited number of possibilities for this input then you should use a drop-down box or a radio button group in your form. That would prevent any incorrect replies.
Otherwise here's how to check a list of valid response:
[list]Drag a Custom Serverside Validation action into the ON Submit event and move it up before any actions other than Anti-Spam checks.
Open it up and add code like this
Save and close the action then drag an Event Loop action into the pink On Fail event box (the default settings for the Event Loop are OK). [/list]
Bob
If you really only allow a limited number of possibilities for this input then you should use a drop-down box or a radio button group in your form. That would prevent any incorrect replies.
Otherwise here's how to check a list of valid response:
[list]
<?php
$ok_values = array(
'case1',
'case2',
'case3'
);
if ( !in_array($form->data['data'], $ok_values ) {
$form->validation_errors['data'] = "Add message here";
return false;
}
?>
Bob
This topic is locked and no more replies can be posted.