PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Advanced Conditional Logic ?

  1. I have a client who wants to have 10 questions all with 3 radio buttons (A, B and C). At the end of the questionnaire an HTML box will display if most of the answers are A, a different one if most of the answers are B, and a different one if most of the answers are C. Is this possible with Gravity Forms? And does my explanation make sense? Thanks! :)

    Posted 11 years ago on Tuesday March 26, 2013 | Permalink
  2. It does make sense. You want to change the confirmation message conditionally based on the answers which are submitted. You will have to total all the C submissions, all the B submissions and all the A submissions and then change the confirmation message dynamically. You can use PHP to count up the number of A, B and C choices, then you can use the gform_confirmation filter to change the confirmation based on which choice was made most often.

    http://www.gravityhelp.com/documentation/page/Gform_confirmation

    Posted 11 years ago on Tuesday March 26, 2013 | Permalink
  3. Thank you for your answer, that is exactly what I want to do! The gform_confirmation page looks easy enough to figure out. Could you point towards a tutorial or a page on how I would add up the selected radio buttons, or how I could hook into this from the functions file? I just bought the plugin today so I am still learning. Thank you!!!!

    Posted 11 years ago on Tuesday March 26, 2013 | Permalink
  4. Please take a look at this code. http://pastebin.com/B1sjjwwQ

    One problem will be if out of 10 questions someone answers where there is no clear "mostly" (i.e. 5 and 5, or 4, 4 and 2.) That is not accounted for in the code, but the approach should be sound.

    Posted 11 years ago on Tuesday March 26, 2013 | Permalink
  5. Thank you!! One quick question, since the answers are going to look like this:

    A. Something here
    B. Something else
    C. Something another

    How, with that code, would I strip all characters except the first? I'm assuming that would be the best solution...

    Thanks!

    Posted 11 years ago on Tuesday April 9, 2013 | Permalink
  6. nvm I figured it out by using:

    for($i = 1; $i <= 10; $i++)
                    $questions[] = substr($lead[$i], 0, 1);

    Thank you so much for your help!!

    Posted 11 years ago on Tuesday April 9, 2013 | Permalink