Skip navigation
Currently Being Moderated

Re-direct from a web form

Jul 12, 2012 10:40 AM

Hi All.


I want to set up a redirect from a web form.


But not just that, I want the re-direct to happen only if a radio button is selected. Once selcted and the submit button is used it re-directs to another page. If the radio button is not selected then no redirect happens, it would take the user to the normal confirmation of the form submition page.


Don't treally understand the code side of BC, just html and css.


I'm sure it's very simple, but not for me.


Can anyone help?




PS, where is the standard form submittion confirmation page kept as I want to tweak it?

  • Currently Being Moderated
    Jul 12, 2012 4:07 PM   in reply to wretcdes

    Hello wretcdes,

    This can be done with a little JavaScript added to the code at the bottom of your form.


    First you will have to grab your validation code at the bottom of the form (do this by, while within your form, clicking on More Actions > Customize Web Form):

    //<![CDATA[   - to -   //]]>


    Go to paste in your code and click the button to make it readable.


    paste the new readable code back where you copied it from.


    on the first line of the validation code:


    function checkWholeFormXXXXX() {


    Change to this:

    function checkWholeFormXXXXX(theForm) {


    Then under the next line with:


    var why ="";


    Paste in this code:


    var radioClick = $('#checkbox').prop("checked");

                         if(radioClick == true){

                                  theForm.action = '/FormProcessv2.aspx?WebFormID=XXXXX&OID={module_oid}&OTYPE={module_oty pe}&EID={module_eid}&CID={module_cid}&PageID=/YOURPAGEHERE';


                        theForm.action = '/FormProcessv2.aspx?WebFormID=XXXXX&OID={module_oid}&OTYPE={module_oty pe}&EID={module_eid}&CID={module_cid}';



    You will need to change the "#checkbox" to the ID of your radio that the user clicks. then swap out the actions, one with the page redirect and one without.


    Then test. 


    Hope this helps,

    Chad Smith | for only $7

    Mark as:
  • Currently Being Moderated
    Jul 13, 2012 7:26 AM   in reply to wretcdes

    no worries, you're almost there.


    First, your  $('CAT_Custom_277189_0') needs to be $('#CAT_Custom_277189_0'), the pound sign lets jQuery know that you're looking for an ID.


    Second, you will need to grab the action of the form you are working on and replace the ones in quotes:


    <form action="/FormProcessv2.aspx?WebFormID=XXXXX&OID={module_oid}&OTYPE={m odule_o ty pe}&EID={module_eid}&CID={module_cid}">


    Just make sure that the & are not &amp;.


    Update those and lets see if we can get this working.


    Chad Smith | for only $7

    Mark as:
  • Currently Being Moderated
    Jul 16, 2012 10:19 AM   in reply to wretcdes

    Two things I notice which might be cause for it not working:


    1. Change:
      1. var radioClick = $(#CAT_Custom_277189_0).prop("checked");
      2. to:
      3. var radioClick = $("#CAT_Custom_277189_0").prop("checked");
      4. (You forgot to add quotes around your jquery selector)
    2. In your form's action attribute wherever you see "&amp;" replace that with just an &
    Mark as:
  • Currently Being Moderated
    Jul 16, 2012 10:24 AM   in reply to thetrickster888

    For the form's action you don't have to worry about the &amp; - the action is going to get replace by the if statement and those &' s are good.


    At this point could you give an example link? Would be easier to see if the form is getting errors.




    Chad Smith | for only $7

    Mark as:
  • Currently Being Moderated
    Jul 17, 2012 8:27 AM   in reply to wretcdes

    Hello Ken,

    Looks good, the only thing I think that is stopping the form is that when you hit submit the form doesn't validate. In the form tag in the onsubmit attribute you have checkWholeForm30768,

    but in the validation code at the bottom you have:

    • checkWholeForm83640
    • submitcount83640

    These numbers need to match to get the form to validate correctly. I've copied your code and placed it on a test page, with matching form numbers the code worked.




    Chad Smith | for only $7

    Mark as:
  • Currently Being Moderated
    Jul 18, 2012 8:25 AM   in reply to wretcdes

    No worries.


    Looks like the form works, but for some reason  your validation doesn't work so it doesn't run the code to redirect.


    I've just placed your form code on a test page and it is working as it should:


    You did have spaces in the module otype in  your if statement at within the validation code



    There are some errors on that page with

    • box.js - Uncaught ReferenceError: Balloon is not defined
    • jquery.cycle.all.js - [cycle] terminating; zero elements found by selector
    • big_menu.css is a 404


    You might try placing the form on a blank page with nothing but the form and see if it works.


    Chad Smith | for only $7

    Mark as:
  • Currently Being Moderated
    Jul 18, 2012 12:14 PM   in reply to wretcdes


    I should have caught that. Great job!


    Chad Smith | for only $7

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points