Forum Moderators: coopster

Message Too Old, No Replies

Multiple IF question

         

michlcamp

4:45 am on Jul 23, 2005 (gmt 0)

10+ Year Member



hoping someone can help me write the code for a hidden field like the one below, only more than one condition...

IF condition1=yes, or IF condition2 = yes, printf(as below)

if $resident =="yes",
or
if $nonprofit=="yes"
printf(etc as below)

I have to use it as a value= in a hidden field to complete the one below.

<input type="hidden" name="shipcalc" value="<?php if ($resident == "yes") {printf ("%01.2f", $total * .085);}else {echo " ";}?>">

Thanks in advance.

zCat

8:06 am on Jul 23, 2005 (gmt 0)

10+ Year Member



<input type="hidden" name="shipcalc" value="<?php if ($resident == "yes" ¦¦ $nonprofit == "yes" ) {printf ("%01.2f", $total * .085);}else {echo " ";}?>">

I presume you check the value in that field when the form is submitted is what you originally put in it.

michlcamp

12:24 pm on Jul 23, 2005 (gmt 0)

10+ Year Member



Well, that worked fine, thanks...
but I overlooked something....

What I'm doing is calculating state tax for an online order - only state residents are taxed. All non-profits (resident or not) are NOT taxed...

IF the customer is a resident
but is NOT a non-profit,
calculate tax (as below)

IF (the customer) is a non-profit
there is NO TAX (regardless of residency or not)

so it would be something like

<input type="hidden" name="statetax" value="<?php if ($resident == "yes" ¦¦ $nonprofit == "no" ) {printf ("%01.2f", $total * .085);}else {echo " ";}?>">

Can do?

omoutop

10:18 am on Jul 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



why dont u use if and elseif afterwards?try it...

i.e.
if $resident =="yes",
{
bla bla bla bla
}
elseif $nonprofit=="yes"
{
blablala
}