Jump to content

Using PHP to subtract a Number from a text field.


designop

Recommended Posts

I have a form where a person is allowed X amount of money to spend.  I also have a javascript to add up what the person puts in to order.  This number auto updates in a text field.  I need a way via PHP to subtract the number in the code from the number in the text field and display somewhere else.

 

Currently I have this:

 

<?php
$number1 = $amount;
$number2 = TOTAL2;
echo $number1 - $number2;
?>

And here is the text field I need to get the value from.  Keep in mind the value auto changes via javascript.  So I cannot just grab the value from that.  Any ideas of what I can do.

 

<input class="amount1" name="TOTAL2" size="5" onfocus="this.form.elements[2].focus()" value="0.00" />

 

 

Thanks for any help!!

You know that they have to submit the form in order for PHP to have a go at the data, correct?  And that they can just modify what's in the text field from Javascript?  You should also add it all up on the PHP side to make sure that it wasn't tampered with. =P

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.