Jump to content
  • 0

Need to ReDirect to Page Based on Dropdown Selection


jayandang
 Share

Question

I have an "update" webform with a dropdown field. The dropdown field (VendorSelection) contains two selections/values (Value 1 and Value 2).

If a user selects Value 1 from my dropdown list, they will be redirected to the page in the Destination and Triggers section of the datapage wizard.

If a user selects Value 2 from my dropdown list, I need them to be redirected to a different datapage and to pass parameters into the webform associated with this datapage. I tried using the following javascript:

function getDeps() {

if

(document.getElementById(\"EditRecordVendorSelection\").value == "Value 2")

{

window.location=\"http://www.myurl.com\";}

}

document.getElementById(\"caspioform\").onsubmit=getDeps;

Unfortunately, the redirect is not happening when Value 2 is selected in my dropdown field. Can someone please, please tell me what I am doing wrong. I'm a javascript newbie. Thanks in advance!

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hi,

Try entering the below script in the footer of your data page and once the user selects the Value 2 from the dropdown, it would redirect them to http://www.myurl.com.

Try This.

function getDeps()

{

var deps = document.getElementById("InsertRecordVendorSelection").value;

if (deps == "Value 2")

{

window.location="http://www.myurl.com";

}

}

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

I hope this solves your problem, if not please provide the URL where we can see the form and the elements , in order to better understand what your trying to do.

Here is a good Java Script resource in http://www.w3schools.com..

Best, :D

Syed

Link to comment
Share on other sites

  • 0

Thanks for your quick response!

I tried this code and the page redirect still isn't working. The form that contains my dropdown field which contains Value 2 is an update form. So I tried:

var deps = document.getElementById("EditRecordVendorSelection").value;

as well as

var deps = document.getElementById("InsertRecordVendorSelection").value;

But neither is working correctly :(

You can access my Update form by doing the following:

1). Click the following link:

http://bridge.caspio.net/dp.asp?AppKey=48fe0000h2g8h2c2g9c7f7h3e9f9

2). Enter "test 1001" into the search box and press the search button

3). My details page with the dropdown field "Vendor Selection" will appear. (Note: This field is the only required field on my update form.)

When "My Favorites" is selected it should redirect users to my URL, but it displays the "Data Submitted Successfully" page from the Destinations and Triggers section of the datapage wizard.

Do you have any additional suggestions?

Link to comment
Share on other sites

  • 0

I figured it out (partially).

If the script ends with getDeps(), it redirects me to my designated URL.

However, I have another issue. After "Value 2" is entered into my dropdown and my page is redirected to my URL, whenever I subsequently access my update form for this record it keeps automatically redirecting to my URL because "Value 2" is selected in my dropdown field.

However, I still need to be able to edit other fields on my Update form after "Value 2" is entered into my dropdown. So, I only want the page to be redirected when I click the "Update/Submit" button on my form when "Value 2" is entered into my dropdown.

Do you know how I can do this?

Thanks again!

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...
 Share

×
×
  • Create New...