calculating quantinty

dezignas 28 Feb, 2011
Hi guys🙂 I'm a bit noob in all forms building stuff🙂

I need to get a from that could calculate total price by quantity for me

It will be a basic form with a name, email in it and quantity, price and total price.

How can this be done ?🙂 Looking in the forum, but didn't quite found anything I searching for🙂
GreyHead 28 Feb, 2011
Hi dezignas,

If you have your form including a text inputs with these ids: id="price", id="quantity", id="total_price"

Then this code in the Form JavaScript box will probably work.
window.addEvent('domready', function() {
  $('price').addEvent('keyup', calc);
  $('quantity').addEvent('keyup', calc);
});
function calc() {
  var price = $('price').value;
  var quantity = $('quantity').value;
  if ( price > 0 && quantity > 0 ) {
    $('total_price').value = $price * $quantity;
  }
});
Not tested and may need debugging.

Bob

Bob
dezignas 28 Feb, 2011
Thank You will try to make this work🙂
This topic is locked and no more replies can be posted.