quote:
Originally posted by krissy-afc
Using PHP?
Using anything really, PHP, Java, I don't mind.
quote:
Originally posted by stoshrocket
php code:
$am = $_POST['amount'];
$ret = ceil($am/0.05);
EDIT:
NB: ceil rounds up to nearest integer value, which I assumed from your post. However, if you needed to round up such that you end up to the nearest pence/cent, you'd have to use round() and an appropriate precision value, along with adding 0.005 to ensure you end up with the correct rounded up value...
php code:
$am = $_POST['amount'];
$ret = round(($am/0.05)+0.005, 2);
EDIT 2:
Thinking about it, dividing an integer with no more than 2 dp by 0.05 (effectively multiplying by 20) will mean there will be at most 1dp, so that last edit can be ignored, but kept for reference
Thanks, but wont that $_POST variable only be retrieved after the form is submitted? or am I being stupid?
I'm trying to make it change instantly, as a new value is entered into the amount box, or if that isn't possible, a button or something to update the total.
And also, I am not trying to round the amount entered, but the amount produced. For example, say someone donated $6.23 (unlikely, yes, but it could happen), that / 0.05 is 124.6. What I would want produced is 125, the nearest whole number. Sorry if I didn't make myself clear.