Submit or redirect on Radio Button form

Michael Purgar asked on May 11, 2016 17:54

Hi everyone -

I'm looking to create a single form where if someone chooses certain options from a list of radio buttons the form will submit, but if they choose others it will redirect them to a webpage or similar to display a message. For example, if the radio buttons look like this:

  • Option 1
  • Option 2
  • Option 3
  • Option 4

Upon submitting the form, if he user selected Option 1 or Option 2 they get redirected to a page with more info, but if they select Option 3 or Option 4 the form submits with their choice as normal. Is there a way to set this up in Kentico?

Thank you so much for the help!

Recent Answers


Laura Frese answered on May 11, 2016 18:47 (last edited on May 11, 2016 19:54)

You could use jQuery

$(".fakebutton").click(function(){
    var selectedval = $("#myradiobuttonlist input[type='radio']:checked").val();
    if(selectedval == "Option1"){
        window.location = "mypath";
    }
    if(selectedval == "Option4"){
        $(".KenticoButtonClassOrID").click();
    }
});
1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 11, 2016 18:56

You really have 3 options to handle your custom code/request:

  • JavaScript to do your checking/redirects
  • Custom event handler (I'd recommend)
  • Custom webpart, derived from the standard Online Forms webpart
0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on May 11, 2016 19:20

Building on the previous comments, my preferred method of doing this is cloning the bizform webpart or online form webpart and creating an onaftersave event. Then you can access the form data and perform your checks, and also do your redirects.

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on May 12, 2016 06:58

Actually, you don't need anything custom. The Form can be configured to redirect you to some url after you submit it. This field can contain macros, so you can check what radio button was selected and then redirect your user to either Thank you page or to More info page. Do you need a macro example?

0 votesVote for this answer Mark as a Correct answer

Michael Purgar answered on May 12, 2016 17:07

Laura: Thank you! I'll play around with that and present it as a possible solution to the bosses.

Jan: If you do have examples of some macros that would be appreciated. I did take a look at the macros but will admit I wasn't seeing how to apply them in this case.

Thanks to everyone for the help so far!

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on May 13, 2016 12:02

Of course, the Redirect to URL property could look like this (where rbf is code name of your radio buttons field):

{%if(rbf=="Option1" || rbf=="Option2"){"~/moreinfopage/"+rbf}else{"~/thankyoupage"}%}

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.