• Resolved uafinsee

    (@uafinsee)


    Hi!

    Is there a way to assign variable value on click of a button in the modern version of plugin?

    On a very old version of this plugin I had a calculate button A with a code in OnClick event

    myvar = 1;

    And another calculate button B with a code

    myvar = 0;

    Then I have a calculate field with code
    if (myvar == 1) {…}

    else if (typeof myvar === ‘undefined’ || myvar === null || myvar == 0) {…}

    And this worked. Now when I update the plugin and click “button A” myvar is still undefined. When I click after that any other calculate button it finally makes myvar = 1 and the correct code executes.

    Same happens when I click “button B” – after first click nothing changes. I need to click another calculate button to change the value of the variable.

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @uafinsee

    Please, follow the steps below:

    1. Assign a different class name to every button, for example: button-a and button-b respectively.

    Note, the class names are assigned to the fields through their attributes: “Add CSS Layout Keywords.”

    2. Insert an “HTML Content” field in the form with the following piece of code as its content:

    
    <script>
    jQuery(document).on('mousedown', '.button-a input', function(){myvar=1;});
    jQuery(document).on('mousedown', '.button-b input', function(){myvar=0;});
    </script>
    

    And that’s all.

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Assign variable value on calculate button’ is closed to new replies.