• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: 2 decimals in form calculating result

2 decimals in form calculating result 12 years 2 months ago #16291

  • werner1977
  • werner1977's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 1
Dear Members,

Kindly I'd like to ask for help with a small problem.

For using a textbox form calculation ( demo.rsjoomla.com/calculation-form-example ) i'm using the following javascript:
<script type="text/javascript">
function calculateText()
{
var op1=document.getElementById('field1');
var op2=document.getElementById('field2');
var result=document.getElementById('Total');
 
if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;
if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;
 
result.value=0;
result.value=parseFloat(result.value);
result.value=parseFloat(result.value)+parseFloat(op1.value)*parseFloat(op2.value)*0.000795;
}
//-->
</script>

When calculation 234*234 (*0.000795) the result is 43.53102

Is it possible to show the result with 2 decimals and a € symbol, like € 43.53

Thank you very much

Kind regards,

Werner
The administrator has disabled public write access.
The following user(s) said Thank You: hcs76

Re: 2 decimals in form calculating result 12 years 1 month ago #16516

  • stratovarius8
  • stratovarius8's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 1
I solved it.

On the Calculate button additional atributes put:

onclick="calculateText(); num=this.form.Total.value; this.form.Total.value=(parseFloat(num)).toFixed(2);"

Ricardo - Brasil
The administrator has disabled public write access.
The following user(s) said Thank You: hcs76
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!