SOLVED

Re: redirecting to different pages depending on form fields chosen

Go to solution
Anonymous
Not applicable

redirecting to different pages depending on form fields chosen

I want the user to go to one default page when a certain product is selected in the form "multi-select" and to a different page when the user chooses the "None Apply" in the 'multi-select'.
This is the JavaScript taken and modified from Marketo help article:
<script type="text/javascript">
function changeFollowupURL()
{
    // first, set the default follow up page
    var URL = 'none';
    
     // override the default based on form values
     // Replace this with your own rules for setting the new URL
     if($jQ("#CitrixProducts").val() == "None apply")
     {
         URL = 'http://www.ncomputing.com/products/nseries';
         $jQ('input[name="returnURL"]').val(URL);
         $jQ('input[name="retURL"]').val(URL);
         $jQ('input[name="returnLPId"]').val('5025');
     }
    else
     {
        URL = 'http://www.ncomputing.com/products/vspace-platform';
        $jQ('input[name="returnURL"]').val(URL);
        $jQ('input[name="retURL"]').val(URL);
        //$jQ('input[name="returnLPId"]').val(URL);
     }
     return true;
}
 
 function formSubmit(elt) 
{
   changeFollowupURL();
   return Mkto.formSubmit(elt);
 }
</script>
Unfortunately I am not getting something right. I am a bit green with JavaScript so any help would be much appreciated.
Thanks
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Rafael_Santoni1
Level 5

Re: redirecting to different pages depending on form fields chosen

David,

Have you already defined $jQ to invoke jQuery? $jQ does not invoke jQuery by default. I don't see anywhere on your code defining $jQ.

The code looks like it should work but I think you need to define the variable $jQ like this:

var $jQ = jQuery.noConflict();

Try inserting that just before the "changeFollowupURL" function.

script type="text/javascript">
var $jQ = jQuery.noConflict();
function changeFollowupURL()

If you had already declared it, we can try looking at other options. Confirm that first.

Also, I am not sure about this line is needed on the code:
    $jQ('input[name="returnLPId"]').val('5025');
...if you are looking to only replace the return URL value.

Good luck!

Rafael

View solution in original post

3 REPLIES 3
Rafael_Santoni1
Level 5

Re: redirecting to different pages depending on form fields chosen

David,

Have you already defined $jQ to invoke jQuery? $jQ does not invoke jQuery by default. I don't see anywhere on your code defining $jQ.

The code looks like it should work but I think you need to define the variable $jQ like this:

var $jQ = jQuery.noConflict();

Try inserting that just before the "changeFollowupURL" function.

script type="text/javascript">
var $jQ = jQuery.noConflict();
function changeFollowupURL()

If you had already declared it, we can try looking at other options. Confirm that first.

Also, I am not sure about this line is needed on the code:
    $jQ('input[name="returnLPId"]').val('5025');
...if you are looking to only replace the return URL value.

Good luck!

Rafael

Anonymous
Not applicable

Re: redirecting to different pages depending on form fields chosen

Can you post your page? What i'm missing is a way for the javascript function to be called. It seems to me that there needs to be an onClick trigger calling this function whenever someone selects a different value in your picklist. 
Rafael_Santoni1
Level 5

Re: redirecting to different pages depending on form fields chosen

The Javascript function is being called upon form submit. David has the overriding formSubmit() calling the changeFollowupURL() function.

i.e.

function formSubmit(elt) 
{
   changeFollowupURL();
   return Mkto.formSubmit(elt);
 }