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.). 



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

 

 

 

Angebot

Sommer Special! Alle Mitgliedschaften zum Sonderpreis!

Prio Support, alle Extensions und alle Templates in einem Paket.

Hier geht's zur Bestellung

Crosstec hilft sparen!

Falls Sie neu bei Crosstec sind aber bereits einen Formulargenerator bei einem anderen Hersteller gekauft haben, dann bekommen sie von uns einen Rabatt von 25% auf unsere 1-Jahres und Pro-Mitgliedschaften

Wie Sie an den Rabatt kommen?

Schreiben Sie uns einfach eine kurze Email mit beigelegten Kaufbeleg (z.B. PayPal Quittung) an sales@crosstec.org.

Wir unterstützen die Joomla Community

Crosstec unterstützt weltweit alle offiziellen Joomla! User Groups und Organisatoren von Joomla! Days die bei Joomla.org registriert sind.

Falls das auf dich zutrifft und du eines unserer Produkte brauchst, schreib uns eine kurze Email an info@crosstec.org und du bekommst eine Flatrate-Mitgliedschaft geschenkt!