If then Else help (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


99bird -> If then Else help (11/17/2005 16:29:25)

I am trying to list a regular price (Price) and in some cases a sale price (spprice) for a item. If a sale price (spprice) is present I want to be able to show the regular price (Price) with a line through it (a stikethrough) and the sale price.
And if there is not a sale price (spprice), show just the regular price(Price). So far I have been able to get it to work using the If, Then, Else statement listed below with exception that when there is not a sale price the regular price still has a strikethrough it in all cases.
I think I have explained correctly.

Any help will be greatly appreciated.
Thanks for all your help in advance.

<% If (FP_FieldVal(fp_rs,"spprice")) > "" then %>
<font face="Verdana" size="2" color="#000000">
<strike><%=FP_FieldVal(fp_rs,"Price")%></strike>  <font face="Verdana" size="2" color="#FF0000"><%=FP_FieldVal(fp_rs,"spprice")%>
<%Else%>
<%=FP_FieldVal(fp_rs,"Price")%>
<% end IF %>




rdouglass -> RE: If then Else help (11/17/2005 19:25:02)

quote:

<% If (FP_FieldVal(fp_rs,"spprice")) > "" then %>


It looks like your problem is using the "FP_FieldVal". That, by default will return a space if the field is Null or empty so it will *never* = "".

What we should do is use:

(FP_Field(fp_rs,"spprice")) 'Notice no 'Val'

and really ensure it will be empty by using trim like so:

<% If trim(FP_Field(fp_rs,"spprice")&"") > "" then %>

(the &"" is in there in case the DB returns a Null. Trim will error on Nulls)

That any help?




99bird -> RE: If then Else help (11/18/2005 8:32:00)

rdouglass,
That did it. Works perfectly. Thank you for you help.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625