Perzival Posted February 12, 2019 Report Share Posted February 12, 2019 I am trying to create a custom Redirect in my DataPage. First off, I have a dropdown which the user will select the value from. If the user select A then he should be redirected to DataPage X, if the user select B then redirect to DataPage Y, if the user selected option C then should be redirected to DataPage Z. Pseudo: If (dropdown.option =='A') { return.redirect(https://DataPageX); elseif (dropdown.option == 'B') { return.redirect(https://DataPageY); elseif (dropdown.option == 'C') { return.redirect(https://DataPageZ); } else {return 'Invalid';} } } Quote Link to comment Share on other sites More sharing options...
Harbinger Posted February 12, 2019 Report Share Posted February 12, 2019 Hi @Perzival This can be achieved using JavaScript. You may just want to use Switch method on that. Here's an article: https://www.w3schools.com/js/js_switch.asp Switch method example: <script> document.addEventListener('FormSubmitted', function(event) { switch (document.getElementByClassName('cbFormSelect').value); { case A: window.location="https://google.com"; break; case B: window.location="https://youtube.com"; break; case C: window.location="https://gmail.com"; break; } }); </script> Note: If you are using a field that is created from the table then make sure to save your URL's in that particular field. If you're using a Virtual field, you may enable custom values and insert your URL's in that field. Important You should pass the field's parameter on exit then choose "go to another page" at the last part of submission. From the URL field, paste the parameter and hit finish. Cheers, ~ H Quote Link to comment Share on other sites More sharing options...
Harbinger Posted February 12, 2019 Report Share Posted February 12, 2019 Alternatively, you may utilize the standard features of Caspio. You may visit this article for another approach: https://howto.caspio.com/tech-tips-and-articles/common-customizations/dynamic-redirects-after-form-submission/ ~ H Quote Link to comment Share on other sites More sharing options...
astroboy Posted July 30, 2021 Report Share Posted July 30, 2021 Hello, You may also utilize parameters to achieve this workflow and tweak the code in this article a little, and paste it to an HTML DataPage to make it work: https://howto.caspio.com/tech-tips-and-articles/common-customizations/create-user-specific-redirect-after-login/ Quote Link to comment Share on other sites More sharing options...
walemark Posted March 9, 2022 Report Share Posted March 9, 2022 Use Javascript: window.location.replace('http://example.com'); It’s better than using window.location.href = ‘http://example.com’; Using replace() is better for javascript redirect because it does not keep the originating page in the session history, meaning the user won’t get stuck in a never-ending back-button fiasco. If you want to simulate someone clicking on a link, use window.location.href If you want to simulate an HTTP redirect, use window.location.replace You can use assign() and replace methods also to javascript redirect to other pages like the following: location.assign("http://example.com"); The difference between replace() method and assign() method(), is that replace() removes the URL of the current document from the document history, means it is not possible to use the “back” button to navigate back to the original document. So Use the assign() method if you want to load a new document, andwant to give the option to navigate back to the original document. Quote Link to comment Share on other sites More sharing options...
Kurumi Posted April 29, 2022 Report Share Posted April 29, 2022 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/' ELSEhttps://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 Quote Link to comment Share on other sites More sharing options...
Kronos Posted October 20, 2023 Report Share Posted October 20, 2023 Hi, if you want to redirect users if they are using mobile or desktop you may try this solution: I hope this helps! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.