Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question OnSubmit Redirect to Separate Urls depending on field value

    I am going bonkers trying to figure this one out. I know I'm not doing this right. Here's what I've got:

    Code:
    $(document).submit(function(){
       if($("input[name=type_of_transaction]").val() == "Purchase") {
    window.location = "http://www.website.com/thanks1.php";
    	}
       if($("input[name=type_of_transaction]").val() == "Refinance") {
    window.location = "http://www.website.com/thanks2.php";
    	}
    });
    I can't use an "onClick" function inline with the submit button because the whole form is generated by javascript code that I cannot modify. So instead I am trying to just write something for when a button is submitted on the page, it redirects to page1 or page2 depending on what radio button has been selected as it is being submitted. A specific button would be great, but any button onSubmit is fine because I can't assign an ID to the button.

    Any suggestions/corrections?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    document does not have submit event, it should be form. But even then, if you change the url while the form is being submitted, the form might not get submitted.

  • Users who have thanked glenngv for this post:

    bevlodge (02-11-2014)

  • #3
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Oh gosh! You are absolutely right - I didn't even think about that

    It looks like I am going to have to formulate a different workaround altogether. I wish Hubspot forms had field logic! Arggg!!!

    Thanks so much for your...er... good point!

  • #4
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Um... I also don't know how to close this thread...


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •