arn_php Posted December 13, 2008 Share Posted December 13, 2008 I am working on this form where (I want to be) if you put a number to the amount field, the amount adjustment field would automatically calculate the number to add the 3% adjustment. Here is the code: Amount: <input name="amount" type="text" value="<?=stripslashes($_POST['amount']);?>" size="5" /> <?php $amount = $_POST['amount']; $total = $amount * 1.03; ?> Amount Adjustment: $US <?php echo $total; ?> But then this is only works if I click the submit button. I want it calculate directly after I fill the number into the amount field before clicking the submit button. How to do that? Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted December 13, 2008 Share Posted December 13, 2008 Use javascript. PHP can only be executed on the server, and while an Ajax call could be used to run a PHP script that multiplies account by 1.03, it would seem a bit excessive using Ajax for something like this when it can easily be done using javascript Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.