× Form Help

Dollar Sign in Subtotals and Grand Total and Two Decimal Places in All Prices

  • NMF101A
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 0

NMF101A created the topic: Dollar Sign in Subtotals and Grand Total and Two Decimal Places in All Prices

I am using the most recent version of BreezingForms Pro (Build 931) and Joomla 3.9.4.

I have created a book order form

File Attachment:

File Name: RAGT-19Boo...Form.zip
File Size:44 KB
which lists books, the amount per book and the quantity of each book ordered. The form multiples the amount of the book * the number of books and places such within a sub-total field for each book.

The GrandTotal element at the bottom of the form displays the total cost of all books ordered.

I have disabled all ActionScripts for each form element and instead have combined all such scripts into the Advanced -> More Options -> Scripts section of the form. The code is modeled after TOMEPERICA's code here: crosstec.org/en/forums/35-form-help/1095...n-help.html?start=12

I have four problems I need to solve and cannot find direct solutions for:

1. All subtotals should be preceded by a dollar "$" sign.

2. The GrandTotal content should be preceded by a dollar "$" sign.

3. All sums should be trailed by 2 decimals ".00"

4. I also want GrandTotal to appear in bold

I have checked numerous forum posts ( crosstec.org/en/support/online-documenta...lculated-amount.html , crosstec.org/en/forums/3-breezingforms-f...-a-form.html?start=6 ) but cannot find a solution that I can implement with my script.

Thank you.
#235194
Attachments:
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 2360
  • Karma: 85
  • Thank you received: 316

mihaela replied the topic: Dollar Sign in Subtotals and Grand Total and Two Decimal Places in All Prices

Hello,

The code in the Initialization script that will work as you wanted and will resolve tasks 1.-3. is:
function ff_RAGT19_BookOrderForm_init()
{
setInterval('myCalc()', 500);
} // ff_RAGT19_BookOrderForm_init


function myCalc() {
	//Calculation for Book1 Subtotal
	ff_getElementByName('Subtotal_KatsStory').value = 0; {
		SubTotal1 = Number (ff_getElementByName('Price_KatsStory').value) * 
		Number(ff_getElementByName('Quantity_KatsStory').value);
		ff_getElementByName('Subtotal_KatsStory').value = '$' + SubTotal1.toFixed(2);
	}
	//Calculation for Book2 Subtotal
	ff_getElementByName('Subtotal_RicksStory').value = 0; {
		SubTotal2 = Number(ff_getElementByName('Price_RicksStory').value) *
		Number(ff_getElementByName('Quantity_RicksStory').value);
		ff_getElementByName('Subtotal_RicksStory').value = '$' + SubTotal2.toFixed(2);
	}
	//Calculation for Book3 Subtotal
	ff_getElementByName('Subtotal_ShoulderToLeanOn').value = 0; {
		SubTotal3 = Number(ff_getElementByName('Price_ShoulderToLeanOn').value) *
		Number(ff_getElementByName('Quantity_ShoulderToLeanOn').value);
		ff_getElementByName('Subtotal_ShoulderToLeanOn').value = '$' + SubTotal3.toFixed(2);
	}
	//Calculation for Book4 Subtotal
	ff_getElementByName('Subtotal_NeedYouNow').value = 0; {
		SubTotal4 = Number(ff_getElementByName('Price_NeedYouNow').value) *
		Number(ff_getElementByName('Quantity_NeedYouNow').value);
		ff_getElementByName('Subtotal_NeedYouNow').value = '$' + SubTotal4.toFixed(2);
	}
	//Calculation for Book5 Subtotal
	ff_getElementByName('Subtotal_ColorMyWorld').value = 0; {
		SubTotal5 = Number(ff_getElementByName('Price_ColorMyWorld').value) *
		Number(ff_getElementByName('Quantity_ColorMyWorld').value);
		ff_getElementByName('Subtotal_ColorMyWorld').value = '$' + SubTotal5.toFixed(2);
	}
	//Calculation for Book6 Subtotal
	ff_getElementByName('Subtotal_UnansweredPrayers').value = 0; {
		SubTotal6 = Number(ff_getElementByName('Price_UnansweredPrayers').value) *
		Number(ff_getElementByName('Quantity_UnansweredPrayers').value);
		ff_getElementByName('Subtotal_UnansweredPrayers').value = '$' + SubTotal6.toFixed(2);
	}
	//Calculation for Book7 Subtotal
	ff_getElementByName('Subtotal_Cocktales').value = 0; {
		SubTotal7 = Number(ff_getElementByName('Price_Cocktales').value) *
		Number(ff_getElementByName('Quantity_Cocktales').value);
		ff_getElementByName('Subtotal_Cocktales').value = '$' + SubTotal7.toFixed(2);
	}
	//Total Sum Calculation 
	ff_getElementByName('grandtotal').value = 0; {
		totalCalc = SubTotal1 + SubTotal2 + SubTotal3 + SubTotal4 + SubTotal5 + SubTotal6 + SubTotal7;
		ff_getElementByName('grandtotal').value = '$' + totalCalc.toFixed(2);
	}            
}
The part that resolves adding a dollar sign is: '$' + ...

The code that trails the sums by two decimals is:
SUM.toFixed(2)

As for the 4. task, to make the GrandTotal appear in bold do as follows.
Go to form's Advanced properties > More options > Form pieces and in the Before Form section set Type to Custom and in the code area below put the following code:
echo '<style> 

#ff_elem2666 {
   font-weight: bold;
}
</style>';
NOTE: You have to replace ff_elem2666 with the ID of that GrandTotal field.

Let me klnow whetehr this works how you wanted and whether you have managed to set it for your form.

Regards,

Mihaela
#235202
  • NMF101A
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 0

NMF101A replied the topic: Dollar Sign in Subtotals and Grand Total and Two Decimal Places in All Prices

Hello Mihaela,

The form worked perfectly. Great and thank you!

However, I forgot to add something that I needed - which is that the dollar sign "$" and two trailing digits ".00" be placed in the Price_BookName fields as well (sorry about that).

I will be trying the solution to bold the GrandTotal later today and will inform you as to how it went.

Thanks again for your help.

Nick
#235254
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 2360
  • Karma: 85
  • Thank you received: 316

mihaela replied the topic: Dollar Sign in Subtotals and Grand Total and Two Decimal Places in All Prices

Hello,

From what I can see in your form, you have already entered in Price_BookName fields amount with two trailing digits ".00".

Furthermore, you have placed the dollar sign "$" in the label before the amount.

If you wanted to change the amount in the field itself to look like "$10.00" for example, then in calculating amounts changes need to be done.

In that case, I suggest that you use the amounts instead of the values collected from the form since they are read-only.

For example, instead of using the variable in this calculation:
ff_getElementByName('Subtotal_KatsStory').value = 0; {
		SubTotal1 = Number (ff_getElementByName('Price_KatsStory').value) * 
		Number(ff_getElementByName('Quantity_KatsStory').value);
		ff_getElementByName('Subtotal_KatsStory').value = '$' + SubTotal1.toFixed(2);
	}
you can use the amount itself:
ff_getElementByName('Subtotal_KatsStory').value = 0; {
		SubTotal1 = 10.00 * 
		Number(ff_getElementByName('Quantity_KatsStory').value);
		ff_getElementByName('Subtotal_KatsStory').value = '$' + SubTotal1.toFixed(2);
When you set the calculation like this, you can simply put the following as value of the Price_KatsStory field:
$10.00

There is also a way to use Price_KatsStory field's value in calculation even though it is defined with a dollar sign, but then additional coding is required to remove the dollar sign before calculating with that value.

Let me know whether this works as you wanted and whether you have managed to set this for your form.

Regards,

Mihaela
#235273
  • NMF101A
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 0

NMF101A replied the topic: Dollar Sign in Subtotals and Grand Total and Two Decimal Places in All Prices

Hi Mihaela,

First, I tried to get the bold text within the grandtotal field as directed. However, when I pasted the code into the form's Advanced properties > More options > Form pieces and in the Before Form section the code broke and saves like this:

echo '<s-tyle>

#ff_elem1936 {
font-weight: bold;
}
</style>';

The code then appears as text before the form - not saving as CSS to be applied to the form element indicated. I tried setting the Joomla editor to None (instead of TinyMCE) but that did not solve the issue.

Kindly let me know what I can do to resolve this.

Next; Yes, the amounts in the Price_BookName fields do have trailing ".00", and those are set within the Element's property value tab, so that's fine.

However, assigning the value within a script defeats the ease of use factor of entering the value within the Element's property tab and will make it more cumbersome to change later.

I guess I'll just leave the dollar sign within the label before the price amount to avoid the extra coding.

So, just kindly help me resolve the issue with the bold in the grandtotal field.

Thanks.

Nick
#235343
Moderators: ForumSupporttomeperica
Time to create page: 0.069 seconds

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here