Jump to content
  • 0

Dynamic Redirects Based On The Checkboxes After Submitting


ppbb123

Question

Is it possible after the end-user clicks the Submit button, I can dynamically redirect a user to a specific URL based on the checkboxes' value?

For example:

There are two checkboxes, "Search1" and "Search2".

If "Search1" is checked, form submission goes to "www.gooogle.com".

If "Search2" is checked, it goes to "yahoo.com".

If neither is checked, it goes to "bings.com"

If both are checked, it goes to "Home.com" .

 

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

1. Create a Virtual field, the destination can be redirected to the value of that Virtual field.

2. Use the following code in the Footer of your DataPages. The value of Virtual1 depends on the checkboxes  :

 

<script>
function myFunction()
{
var x = document.getElementById("InsertRecordSearch1");
var y = document.getElementById("InsertRecordSearch2");
if ((x.checked == true) && (y.checked == false)){
  document.getElementById("cbParamVirtual1").value = "http://www.google.com/";}
else if ((x.checked == false) && (y.checked == true)){
  document.getElementById("cbParamVirtual1").value = "http://www.yahoo.com/";}
else if ((x.checked == false) && (y.checked == false)){
  document.getElementById("cbParamVirtual1").value = "https://www.bings.com/";}
else {
  document.getElementById("cbParamVirtual1").value = "https://www.home.com/";}
}


document.getElementById("caspioform").onsubmit=myFunction;
</script>

3. You can configure what happens after the form is submitted. In the Destination and Triggers page, select Go to a new page as the destination and enter or insert the parameter name in Page URL which is [@Virtual1] in this case.

Link to comment
Share on other sites

  • 0

1. Create a Virtual field, the destination can be redirected to the value of that Virtual field.

2. Use the following code in the Footer of your DataPages. The value of Virtual1 depends on the checkboxes  :

 

<script>
function myFunction()
{
var x = document.getElementById("InsertRecordSearch1");
var y = document.getElementById("InsertRecordSearch2");
if ((x.checked == true) && (y.checked == false)){
  document.getElementById("cbParamVirtual1").value = "http://www.google.com/";}
else if ((x.checked == false) && (y.checked == true)){
  document.getElementById("cbParamVirtual1").value = "http://www.yahoo.com/";}
else if ((x.checked == false) && (y.checked == false)){
  document.getElementById("cbParamVirtual1").value = "https://www.bings.com/";}
else {
  document.getElementById("cbParamVirtual1").value = "https://www.home.com/";}
}


document.getElementById("caspioform").onsubmit=myFunction;
</script>

3. You can configure what happens after the form is submitted. In the Destination and Triggers page, select Go to a new page as the destination and enter or insert the parameter name in Page URL which is [@Virtual1] in this case.

 

Hi,

 

I would like to redirect the user to a specific page after the form is submitted according to the option selected in  a dropdown!

 

I tried the following script but unfortunately it´s not working yet:

 

1) I created a Virtual field to redirect to the value of this Virtual field.

2) I Used the following code in the Footer of my DataPage. The value of Virtual1 should be defined by the dropdown selection!

 

 

<script language="JavaScript">
 
function myFunction()
{
var x = document.getElementByName("InsertRecordMyOption")[0];
if (x == 'Yes'){
  document.getElementById("cbParamVirtual1").value = "http://www.google.com/";}
else if (x == 'No'){
  document.getElementById("cbParamVirtual1").value = "http://www.yahoo.com/";}
else if (x == 'Maybe'){
  document.getElementById("cbParamVirtual1").value = "https://www.bings.com/";}
}
 
document.getElementById("caspioform").onsubmit=myFunction;
</script>
 
I set the [@Virtual1] field as form element "Hidden"
 
could someone give me a hand?
 
Regards!
 
Luiz 
Link to comment
Share on other sites

  • 0

Can you help me with this script? I created a hidden virtual field (Virtual1) that should contain my links below based on given conditions. Then, I want to use that Virtual1 field to redirect the user upon form submission. I tried putting the codes in an HTML block then in the Footer but it seems like the Virtual1 field is not getting any value. Please help.

<script type="text/javascript">
var WorkOrderType = '[@field:WorkOrderType]';
var WorkOrderDetail = '[@field:WorkOrderDetail]';

if (WorkOrderDetail == 'M1 TDM')
{
document.getElementById("cbParamVirtual1").value = "http://b6.caspio.com/dp.asp?AppKey=b9443000bc1de4154c364d53a0b5&WorkOrderId=[@field:WorkOrderId]";
}
Else if (WorkOrderDetail == 'M1 Fiber')
{
[@Virtual1]="http://b6.caspio.com/dp.asp?AppKey=b94430008aaa7fbc77eb48df83f8&WorkOrderId=[@field:WorkOrderId]";
}
Else
{
[@Virtual1]="http://b6.caspio.com/dp.asp?AppKey=b9443000fa23580f2eda4a41bb40&WorkOrderId=[@field:WorkOrderId]";
}
</script>
Link to comment
Share on other sites

  • 0

If you want to redirect a User if he selects special checkbox you can use the following script: 

<SCRIPT LANGUAGE="JavaScript">

                   
 function myFunction()
{
   
  if (document.getElementById('InsertRecordcheckbox').checked)
                {
  
             window.location="http://www.google.com.ua";
             return false;
                 }
}


document.getElementById('caspioform').onsubmit= myFunction;


</SCRIPT>

Hope it helps. 

 

Aurora

Link to comment
Share on other sites

  • 0

Hi - Just an update, you may now use Virtual Field and Calculated Value on this workflow.

You may use a Virtual Field as a holder or identifier of the value from the dropdown and then set the Form Element as Calculated Value. In the Formula, you may use a CASE WHEN statement like:

CASE WHEN [@FIELDNAME] = 'value'
THEN 'https://www.google.com/'
WHEN [@FIELDNAME] = 'value 1'
THEN 'https://caspio.com/'
ELSE
https://www.youtube.com/
END

After setting up the formula, on the Destination and Messaging configuration screen, set the Destination after the record submits to 'Go to a New Page'. Lastly, in the Page URL, call the Virtual Field from the field picker.

For reference, you may check these links:

https://howto.caspio.com/datapages/datapage-components/virtual-fields/
https://howto.caspio.com/datapages/datapage-components/calculated-values/
https://howto.caspio.com/function-reference/
https://howto.caspio.com/datapages/forms/submission-forms/#:~:text=to make conditional.-,Destination and Emails,-Here you can

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...