• Resolved julien66

    (@julien66)


    Hello,
    I have a form that computes either calculation field A or calculation B depending on what the user chooses for an initial radio button.

    After the user hits Submit I would like to show the result of either A or B in the Inline Message. But I can’t find a way to use a condition based on the initial radio button in the editor.

    Would there be a way to do that?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @julien66

    I hope you are doing good today.

    I’m afraid this will be not possible when it comes to showing messages on the front end. However maybe one of those solution will be better:

    1. create 2 additional HTML fields with your custom messages and set up for each of those fields conditional logic in a way that will show up only when A or B is selected. Any of those HTML fields will show up before they will click on Submit.

    2. create additional Email Notifications base on your conditional logic. So in the end you will have 2 Email Notifications with different text messages base on that conditional logic.

    Kind Regards,
    Kris

    Thread Starter julien66

    (@julien66)

    Thanks Kris for proposing 2 solutions! But I can’t use them as I don’t use emails and it needs to show up after submit.

    I see in the Inline Message editor, there’s a possibility to use \<code\>. Would you know if there’s a way to use some PHP to access the value of the fields from the form?

    Thanks

    • This reply was modified 3 years, 3 months ago by julien66.
    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @julien66

    The “code” element wouldn’t let you use PHP anyway, regardless whether you can access fields values. It’s just a HTML tag to let you display code on page…

    But I think there is a way and it’s similar to the 1st solution that Kris suggested.

    I’m assuming that “computes either calculation field A or calculation B depending on what the user chooses for an initial radio button” means that:

    – you have two “calculations” type fields in form
    – and depending on radio button choice only one of them is shown (regardless of whatever they calculate)
    – so that’s based on “Visibility” conditions and both calculations are giving different results

    Is that about right?

    If yes, you can do this:

    – put the third calculations field on form (let’s say it’s {calculation-3})
    – optionally set it to be hidden
    – assuming that your “Calculation A” and “Calculation B” are, accordingly, fields “{calculation-1}” and “{calculation-2}”, put this formula in {calculation-3} field:

    {calculation-1}+{calculation-2}

    – in your “Inline Message” simply use {calculation-3} in text where you want to display the value.

    I’ve created a basic example form for you to demonstrate such approach:

    https://pastebin.com/CcHF29qu

    Best regards,
    Adam

    Thread Starter julien66

    (@julien66)

    Hi @wpmudev-support8

    Yes that’s exactly my use case: calculating 1 calculation or the other depending on the user choice for the radio button.

    And yes, your solution works perfectly fine! Thank you so much for taking the time to properly explain this trick!!

    Thanks a lot Adam!

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @julien66,

    Glad to hear it’s working fine now. Have a great day ahead.

    Best Regards,
    Nithin

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Conditional Inline Message’ is closed to new replies.