PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Nov 23, 2014 2:07 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Nov 25, 2011 8:20 pm 
Offline
Forum Contributor

Joined: Sun Apr 12, 2009 11:31 am
Posts: 208
Hey all I am not sure this is the right place to post this so if its not I apoligize but here is what I am trying to do.

I have a form

<form action="calc.php" method="post">
<table>
<tr><td width="48">Amount</td><td width="128"><input name="amt" type="text" value="<?php echo $_POST['amt']; ?>" size="8" maxlength="8" /></td></tr>
<tr><td>Percent</td><td><input name="per" type="text" value="<?php echo $_POST['per']; ?>" size="8" maxlength="8" /></td></tr>
<tr><td><select name="days">
<option value="daily" selected="selected">Daily</option>
<option value="after">After</option>
</select></td><td><input name="days2" type="text" value="<?php echo $_POST['days2']; ?>" size="8" maxlength="8" />
days</td></tr>
<tr><td colspan="2"><input name="go" type="submit" value="Calculate" /></td></tr>
<tr><td>Total</td><td><?php echo $total;?></td></tr>


</table></form>


which is basic table as you see now i have this as php code at the top


Syntax: [ Download ] [ Hide ]
<?php

if(isset($_POST['go'])) {
       
        if($_POST['days'] =='daily') {
$total = $_POST['amt'] * $_POST['per'] / 100 * $_POST['days2'];
        }

        if($_POST['days'] =='after') {
$total = $_POST['amt'] * $_POST['per'] / 100 * 1;      
        }

}


?>



My task is I need to submit this to get the results WITHOUT refreshing I have read its jquery and JS but I am lost when it comes to this. I have looked at samples but no luck any help would be nice.

Thanks


Top
 Profile  
 
PostPosted: Sat Nov 26, 2011 5:18 am 
Offline
Forum Contributor

Joined: Sat Oct 22, 2011 10:50 am
Posts: 159
You sure wouldn't want to use JQuery for this, as there's no communication to the server necessary as far as I can see. The client-machine is more than capable of performing mathematics, so let it. Just embed a JS calculator from one of many thousands of sources on google.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group