PDA

View Full Version : Auto calculator



Ferretlodge
09-19-2007, 06:04 AM
Hi dont know if this can be done but i would like to have an auto calcculator for my ferret boarding we charg 2.50 a day so I would like to be able to add the date they arive and it would auto add 2.50 a day :) :confused:

djr33
09-19-2007, 04:46 PM
Fairly simple.

Just multiply the number of days times 2.5, then display it.

But we'd need to know the layout of your site to see how it would fit in.

One thing you'll need to decide--
Do you want it to be live on the page as the user enters the info or should this happen after the form has been submitted and page has loaded again?

Ferretlodge
09-19-2007, 06:32 PM
Fairly simple.

Just multiply the number of days times 2.5, then display it.

But we'd need to know the layout of your site to see how it would fit in.

One thing you'll need to decide--
Do you want it to be live on the page as the user enters the info or should this happen after the form has been submitted and page has loaded again?

ow thats great :D just a wight background and whatever is easer :D

djr33
09-19-2007, 06:40 PM
<form name="calculator" action="?calc" onSubmit="this.cost.value = this.days.value*2.5;return false;">
Number of days: <input name="days" type="text" value="<?php echo $_POST['days']; ?> "><br>
Cost: <input type="text" name="cost" disabled value="<?php echo (@$_POST['days']*2.5); ?>"><br>
<input type="submit" value="Calculate">
</form>

Something like that?


Note that the PHP code acts as a backup if javascript isn't enabled on the users' computers. However, you must have PHP installed on your server and the page must end with a .php extension. If not, remove those value= attributes entirely, and know that the user must have javascript.

Ferretlodge
09-19-2007, 07:25 PM
<form name="calculator" action="?calc" onSubmit="this.cost.value = this.days.value*2.5;return false;">
Number of days: <input name="days" type="text" value="<?php echo $_POST['days']; ?> "><br>
Cost: <input type="text" name="cost" disabled value="<?php echo (@$_POST['days']*2.5); ?>"><br>
<input type="submit" value="Calculate">
</form>

Something like that?


Note that the PHP code acts as a backup if javascript isn't enabled on the users' computers. However, you must have PHP installed on your server and the page must end with a .php extension. If not, remove those value= attributes entirely, and know that the user must have javascript.
That is exslent just what I wanted THANKS :D :D :D :D