Jump to content
  • 0

Taking Variable from a drop down to point to a form/URL


smpforms

Question

Just wondering how I can easily take a variable from a drop down selection in an html editor and then point to a specific URL so that my customer would know they are now filling out a form that was relevant to their drop down selection. Obviously I appreciate your generosity as this must be a very basic web function :oops:

Thanks in advance !!

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Hello,

You can try something like this. Of course, you can/need to modify it based on your field names/URLs.

The following JavaScript is inserted in an HTML block on my DataPage(a Webform). I have a state field which is a drop down. When users selects CA from the drop down it takes them to http://www.caspio.com, else it goes to http://www.w3schools.com. Hope this helps.

=================================================================================

function dynamic_URL()

{

var v_state_ind = document.getElementById("InsertRecordState");

var state=v_state_ind.options[v_state_ind.selectedIndex].text;

if (state.match("CA"))

{

window.open("http://www.caspio.com");

}

else

{

window.open("http://www.w3schools.com");

}

}

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

Best,

-SO

Link to comment
Share on other sites

  • 0

Thanks for your response and I think I am almost there... if I have multiple drop down options that require unique URL's as their destination, how would I duplicate the code you have for each value and then point that to the Unique URL. For instance, what if you had options for multiple states in addition to California ?

Going out on a limb here, but its like I have multiple IF statements, If CA is selected in the drop down go to this URL, if PA is selected go to another URL etc... Yes, I am a rookie...

Thanks again !

Link to comment
Share on other sites

  • 0

Thanks for your help as I am now getting the drop down values to call specific URL's. One last piece, how would I open the URL within the same window by tweaking the script ? I would also like to avoid saying that the submission was correct and just go to the new page... I believe this is the last piece of information I need to make this project a success. Thanks again !!!

Link to comment
Share on other sites

  • 0

Hello,

You might try something like this:

function dynamic_URL()

{

var v_state_ind = document.getElementById("InsertRecordState");

var state=v_state_ind.options[v_state_ind.selectedIndex].text;

if (state.match("CA"))

{

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

}

else if (state.match("PA"))

{

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

}

else if (state.match("NY"))

{

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

}

}

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

Best,

-SO

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