Page 1 of 1

Help with code in hidden field

Posted: Mon Jul 18, 2005 11:09 pm
by michlcamp
I have to put this code into a hidden field named "shipping" so I can pass it to the next form

<?php if ($total > 81.75) {printf ("%01.2f", $total * .11);}else {echo "8.99 ";}?>

so far no luck - I can get the code to display on the page, but get parse errors when I try to put it in a hidden field

<input type="hidden" name="shipping" value="<?php if ($total > 81.75) {printf ("%01.2f", $total * .11);}else {echo "8.99 ";}?>">

Any help much appreciated. Not a brand newbie but I'm still learning...

Posted: Tue Jul 19, 2005 3:55 am
by djot
the code works, do not see any problem:

Code: Select all

<?php
$total=90;
?>

<form>
<input type="hidden" name="shipping" value="<?php if ($total > 81.75) {printf ("%01.2f", $total * .11);}else {echo "8.99";}?>">
</form>