In this example we will insert the $ symbol in front of the figure resulting from different calculations with other elements.

Having two elements of type list selection and a text element that displays the result of the sum of the values of both lists, making a normal calculation the value is displayed, but not the euro symbol (or dollar). So having two selection lists:

- List 1 (name list1):

0; Product A;250

0;Product B;290

0;Product C;320

- List 2 (name list2):

0; Extra A;35

0;Extra B;49

0;Extra C;70

- Text element which show the final result with name 'result'.

Thus, in each of the selection lists > Advanced, we will create both custom action scripts to trigger the calculation. For example, the code for the first list looks like: 

function ff_list1_action(element,action)
{
switch (action) {
 case 'change':
        ff_getElementByName('result').value = 0;
        ff_getElementByName('result').value = (Number(ff_getElementByName('list1').value) +  Number(ff_getElementByName('list2').value));
      break;
 default:;
 } // switch
} //function ff_list1_action}

To add the $ symbol at the beginning of the number to be displayed in the result element, we vary slightly the above code:

function ff_list1_action(element,action)
{
switch (action) {
 case 'change':
        ff_getElementByName('result').value = 0;
        ff_getElementByName('result').value = '$' + (Number(ff_getElementByName('list1').value) +  Number(ff_getElementByName('list2').value));
      break;
 default:;
 } // switch
} //function ff_lista1_action

 

 

 

Special Offer

Summer 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!