designop Posted August 26, 2008 Share Posted August 26, 2008 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!! Link to comment https://forums.phpfreaks.com/topic/121466-using-php-to-subtract-a-number-from-a-text-field/ Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 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 Link to comment https://forums.phpfreaks.com/topic/121466-using-php-to-subtract-a-number-from-a-text-field/#findComment-626398 Share on other sites More sharing options...
designop Posted August 26, 2008 Author Share Posted August 26, 2008 No they cannot edit the text field. I have java code to not allow it. No I did not know about php not being able to pull from a text field. I guess I will have to use javascript. Thanks Link to comment https://forums.phpfreaks.com/topic/121466-using-php-to-subtract-a-number-from-a-text-field/#findComment-626450 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 They can turn Javascript off. And PHP CAN pull from a text field, but not without submitting it. Link to comment https://forums.phpfreaks.com/topic/121466-using-php-to-subtract-a-number-from-a-text-field/#findComment-626451 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.