469,934 Members | 1,753 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

Asp If statement with condition

229 100+
Hi, I have this IF statement

Expand|Select|Wrap|Line Numbers
  1.                     <%
  2. If rsCard("DefaultMessage")="e-card" Then
  3. %>
  4.  
  5.  
  6. <a href="cards.asp?Post=<%=rsCard("Post")%>">
  7. <%
  8. Else
  9. %>
  10. <a href="gallery.asp?author=<%=rsCard("author")%>">
  11. <%
  12. End If
  13. %>
  14.  
  15. <I><%=rsCard("DefaultMessage")%></I><a> 
The default message will include other text apart from the word e-card. What I need is for the IF statement to say. IF the default message includes the word e-card in it somewhere, then xxxxxx else xxxxxxxx
and not if it is equal to e-card.
Anyone know if this is possible?

Thanks for any help in advance.
Richard
Oct 16 '07 #1
2 5153
markrawlingson
346 Expert 100+
Sure it is... Use the InStr method.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. 'If the word "e-card" appears in rsCart("DefaultMessage") at least once..
  3. If InStr(rsCard("DefaultMessage"),"e-card") > 0 Then
  4. %>
  5. <a href="cards.asp?Post=<%=rsCard("Post")%>">
  6. <%
  7. 'if it does not include the word "e-card" at least once...
  8. Else
  9. %>
  10. <a href="gallery.asp?author=<%=rsCard("author")%>">
  11. <%
  12. End If
  13. %>
  14. <I><%=rsCard("DefaultMessage")%></I><a>
  15.  
Hope this helps.
Sincerely,
Mark
Oct 16 '07 #2
fran7
229 100+
Dear Mark,
Thanks worked a treat.
I have had such geat help from this forum.
Thanks
Richard
Oct 16 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

28 posts views Thread by Fábio Mendes | last post: by
8 posts views Thread by Henk van Winkoop | last post: by
3 posts views Thread by Ben R. | last post: by
7 posts views Thread by reon | last post: by
22 posts views Thread by John | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.