• 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: calculator javascript

calculator javascript 14 years 4 weeks ago #13144

  • sales09
  • sales09's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hi

How can I go about changing the below script to times (x) the result instead of adding (+)

eg: Width 5 Length 5 Total= 25

function calculateText()
{
var op1=document.getElementById('Width');
var op2=document.getElementById('Length');
var result=document.getElementById('Total');

result.value=0;
result.value=parseInt(result.value);
result.value=parseInt(result.value)+parseInt(op1.value)+parseInt(op2.value);
}

Any help would be great!

Cheers
Dallas
The administrator has disabled public write access.

Re:calculator javascript 14 years 4 weeks ago #13152

Hi Sales09:

I'm not quite sure what your script is doing, but if you're looking for multiplication, "*" is the multiplication operator. For example:

area = width * height;

I hope that helps.

CM
The administrator has disabled public write access.

Re:calculator javascript 14 years 4 weeks ago #13153

  • sales09
  • sales09's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Yes thanks for the reply.

I just had to change this line below.

result.value=parseInt(result.value)+parseInt(op1.value)+parseInt(op2.value);

to

result.value=parseInt(result.value)+parseInt(op1.value)*parseInt(op2.value);

Cheers
The administrator has disabled public write access.
  • 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!