• Resolved rpalex

    (@rpalex)


    Is it possible to add Custom Javascript and CSS to individual forms and fields in the Forminator Form? I can see that there is a place for adding Custom CSS for each field, but do you have any examples on how to do that?

    Likewise, what about for Javascript or PHP?

    Based on the selection that the User makes in a Dropdown (DD) list, is it possible to take the value from another field, such is
    if (DDUserSelected == “A”)
    then <use the value of Calculated field A>
    if (DDUserSelected == “B”)
    then <use the value of Calculated field B>
    .. and so on…

    • This topic was modified 4 years, 2 months ago by rpalex.
    • This topic was modified 4 years, 2 months ago by rpalex.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @rpalex,

    Thank you for reaching out to us.

    Forminator allows adding custom CSS to customize your form using CSS. However, PHP and JavaScript cannot be applied on the form out of the box.

    `Based on the selection that the User makes in a Dropdown (DD) list, is it possible to take the value from another field, such is
    if (DDUserSelected == “A”)
    then <use the value of Calculated field A>
    if (DDUserSelected == “B”)
    then <use the value of Calculated field B>`

    This should be possible by adding conditional logic on form fields. Please find more details regarding the same in our documentation here (Conditional Logic
    ): https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#forminator-fields

    I hope that helps.

    Kind Regards,
    Nebu John

    Thread Starter rpalex

    (@rpalex)

    Thanks for the response. I tried to place a simple CSS like this

    .calculation-1 {
    color:red;
    }

    and added “calculation-1” in the Additional CSS Styling tab, but nothing happened. So if I have a field like {calculation-1}, could you be help me apply a custom CSS to that field?

    Also, on my second question, is it possible to pick the value of a one field based on a radio selection by the User?

    Example: I have two calculated fields HALF-YEAR and FULL_YEAR payment.
    I have radio button “Do you want to pay HALF or FULL”
    Based on that selection I should be able to copy the value of HALF-YEAR or the FULL-YEAR Calculated field to another Text field for further payment processing.
    Is it possible to do that?

    Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @rpalex !

    Regarding the CSS I’ve shared an example in the other ticket you have, hope that one helps 🙂

    Regarding the second question:

    You can do this, except instead of copying the value you can do this as such:

    1. Radio – each option set to have value of 1
    2. Calculation 1: {radio-1} * your_amount for half (visible only if option 1 is selected), can be hidden
    3. Calculation 2: {radio-1} * your_amount for full (visible only if option 2 is selected), can be hidden
    3. Calculation 3: {calculation-1} + {calculation-2} – this is the result you can use in a payment field for example

    Best regards,
    Pawel

    Thread Starter rpalex

    (@rpalex)

    Thank you Pawel for that suggestion. But I am afraid that may not work. Because the scenario is as follows. This is actually for a Child Sponsorship program. So a User can sponsor one or more Children, and they have the option to pay either the Half year commitment or the full year commitment right now. So please consider the following scenario.

    Cost of Subscribing a child is $100 per year per child.

    User is given a Number button to select the number of children they like to sponsor.
    Say, User selected Three (3) children. So the Semi-annual commitment is $150 and the Annual commitment is $300.

    And I have those values in Calculation 1 & Calculation 2.

    Now the next question is “Do you want to pay the full or half year commitment” as a Radio button.

    Let’s say they selected Half year. So now I need to Copy or Pass the Calculation 1 value to PayPal.

    If they chose Full year, then I need to pass the Calculation 2 value to Paypal.

    Since Calculation 1 already holds $150 and Calculation 2 holds $300, if I just add them in Calculation 3 and use that, then it will be wrong amount.

    In the example you suggested, the “your amount for half” and “your amount for full” is fixed. But in our scenario, it is a changing value. Sorry I didn’t make that clear!

    That is where we are having difficulty.

    • This reply was modified 4 years, 2 months ago by rpalex.
    • This reply was modified 4 years, 2 months ago by rpalex.
    • This reply was modified 4 years, 2 months ago by t-p.
    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @rpalex

    I hope you are doing well.

    In those cases you need to use a “fixed” calculation field, so for example.

    calc-1, calc-2 & calc-3

    Calc 1 = 10+2
    Calc 2 = 30+2

    Calc 3 = ( Calc 1 ) + ( calc 2 )

    If you add the conditional to calc 1 and 2 it will only apply the value if the field is visible, so let’s say calc1 is visible and calc 2 no, so calc-3 will be 12 + 0 which, you use only this calc 3 in PayPal and it will be kind of dynamic based on other calculations.

    Just use parentheses example ( {calculation-1} ) it prevents some issues when hiding the fields.

    Let us know if you need any further information.

    Best Regards
    Patrick Freitas

    Thread Starter rpalex

    (@rpalex)

    Hi Patrick,

    PERFECT! Thank you. That worked. I didn’t know it does not apply the value if the field is not visible.

    I have to create two more hidden fields to display the information to User when

    
    {number-1} -> # of memberships required
    Calc 1 = {number-1}*100  - These two always displayed and shows both values
    Calc 2 = {number-1}*200  - Annual Subscription
    
    Calc 3 = {number-1}*100  - This is hidden and only displays depending on {radio-1}
    Calc 4 = {number-1}*200
    
    {radio-1} -> Do you want to pay half or full year now?
    
    {calculation-5} = ({calculation-3})+({calculation-4})
    

    Viola!
    Thank you for your support.

    • This reply was modified 4 years, 2 months ago by rpalex.
    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @rpalex

    You are welcome,

    I am marking this as resolved, feel free to ping us any time you need.

    Best Regards
    Patrick Freitas

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Custom Javascript & CSS, conditional select’ is closed to new replies.