Forums

make a field auto-completion?

hilas 05 Oct, 2011
Hello everyone

I would like to help me in please NEXT

I need to do that when I enter a numerical value in a text box will automatically fill in certain values ​​the other text boxes .. I mean ..


Box 1: The value income 20,000 (I click outside the box or some other form of update)

Box 2: automatically multiplies the value in box 1 by 0.19, I mean: Box 1 * 0.19 = (reslutado)
and well, the result shows me in box 2

Box 3: automatically makes the sum of box 1 to box 2, I mean: box 1 + box 2 = Result
the result is shown in Box 3
please need help and I tried and failed to do,

pd: I'm doing the form as easy
GreyHead 06 Oct, 2011
Hi Hilas,

What are the ids of the form inputs and what code have you tried?

Bob
hilas 06 Oct, 2011
you mean "field id", on the properties of text box?

If I am correct would be THE FOLLOWING. .

box "Monto" (box 1)
field name: monto
Field id: 10


box "IVA" (box 2)
field name: iva
field id: 20

box "Total" (Box 3)
field name: total
field id: 30

thanks !
GreyHead 06 Oct, 2011
Hi Hilas,

Yes, but ids should never begin with a number; that's not permitted in the HTML rules and will cause problems.

Make them meaningful instead: 'monto', 'iva' and 'total' are good.

The add this to the Form JavaScript box:
window.addEvent('domready', function() {
  $('monto').addEvent('keyup', function() {
    $('iva').value = parseFloat($('monto').value) * 0.19;
    $('total').value = parseFloat($('monto').value) + parseFloat($('iva').value);
  });
});

Bob
hilas 06 Oct, 2011
thanks bob .. and sorry for this .. but i dont understand very much about ..this .. can u explain step by step plz wath to do ? Thanks !
This topic is locked and no more replies can be posted.