I need to have my users put numbers in a text field and then show a total amount. Can I do that?

The following instructions are addressed to the Quickmode but can also be used in Easy and Classicmode.


ADDITION : Example: number1 + number2 = total

  1. Create an element where a single price will be entered or selected (textfield and/or select-list allowing a
    choice of one option only) with properties as follows:

    Label: First Price
    Name: number1

    Go to the Advanced tab of the element. In the Actionscript section, click the "Custom" button. For the Action type,
    check the "Change" checkbox. In the code section, enter:

    function ff_number1_action(element, action)
    {
    ff_getElementByName('total').value =
    Number(ff_getElementByName('number1').value) +
    Number(ff_getElementByName('number2').value);
    }
    // ff_number1_action

    Now click on the "Save Properties" button at the bottom of the page to save the element.

    NOTE: the ‘name’ shown in red in the example below should be the same in all instances. So if you name
    your element Product1 instead of number1, then the code should be:

    function ff_Product1_action(element, action)
    {
    ff_getElementByName('total').value =
    Number(ff_getElementByName('Product1').value) +
    Number(ff_getElementByName('number2').value);
    }
    // ff_Product1_action

    (That text would need to be changed in ALL instances of the code for each element.)


  2. Create a second element where a single price will be entered or selected (textfield and/or select-list
    allowing a choice of one option only) with properties as follows:

    Label: Second Price
    Name: number2

    Go to the Advanced tab of the element. In the Actionscript section, click the "Custom" button. For the Action type,
    check the "Change" checkbox. In the code section, enter:

    function ff_number2_action(element, action)
    {
    ff_getElementByName('total').value =
    Number(ff_getElementByName('number1').value) +
    Number(ff_getElementByName('number2').value);
    }
    // ff_number2_action

    Now click on the "Save Properties" button at the bottom of the page to save the element.

  3. Create a textfield element as follows:

    Label: Total
    Name: total

    Go to the Advanced tab of the element. Put a checkmark in the "Readonly" checkbox. (That way, a user can’t
    change the total amount calculated.) In the Actionscript section, click the "Custom" button. For the Action type,
    NONE of the boxes should be checked. In the code section, enter:

    function ff_total_action(element,action)
    {
    ff_getElementByName('total').value = 0;
    {
    ff_getElementByName('total').value =
    Number(ff_getElementByName('number1').value) +
    Number(ff_getElementByName('number2').value);
    }
    }
    // ff_total_action


    Click on the "Save Properties" button at the bottom of the page to save the element. Then click on the SAVE icon

    in the upper right-hand corner of the screen to save the form itself.



The code for Subtraction Multiplication and Division is pretty the same. All you need to do is to replace the operand " + " with " - " , " * "  or " / "   

 

 

 

Special Offer

Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!