Jump to content

JavaScript If...Then


Recommended Posts

Afternoon Everyone,

Here is my issue. I have a Permissions form I am creating. Where the user must give permission that his/her data is able to be used for our research. If they select "Yes" they will be directed to an info page, if they select "No" they are directed to a we cannot allow you to complete the survey, would you like to reconsider page. I am a beginner JavaScript user...and have a basic idea of JavaScript that should be used, found an example elsewhere in the site, but have changed it around so much I have no idea why it isn't working. So any help would be appreciated:

function dynamic_URL()

{

if (Permission=="Yes")

{

window.open("http://www.cohs.uci.edu/nursing/VTE/VTE3.htm");

}

else

{

window.open("http://www.cohs.uci.edu/nursing/VTE/VTE7.htm");

}

}

document.getElementById("caspioform").onsubmit = dynamic_URL;

Thanks!

Kendra Hosseini

Programmer Analyst

UCI - Program in Nursing Science

Link to comment
Share on other sites

Hi Kendra,

I understand that this issue is solved by the program we discussed. Let me share the code here for others' reference, too. The basic idea is to assign the correct URL link to a virtual field (cbParamVirtual1) based on user selection, and then use this virtual field as the destination of the current DataPage.

function redirect()

{

var YesOrNo = document.getElementById("InsertRecordFIELDNAME");

var w = YesOrNo.selectedIndex;

var selected_text = YesOrNo.options[w].text;

if (selected_text == "Yes"){

document.getElementById("cbParamVirtual1").value = "http://www.cohs.uci.edu/nursing/VTE/VTE3.htm";

}

else{

document.getElementById("cbParamVirtual1").value = "http://www.cohs.uci.edu/nursing/VTE/VTE7.htm";

}

}

document.getElementById("caspioform").onsubmit = redirect;

By changing the 'FIELDNAME' to the correct field name and change the URLs, this piece of code will work for a submission form.

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
Reply to this topic...

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