Solved

Display based on condition ASP/VB

Posted on 2011-02-28
9
276 Views
Last Modified: 2012-05-11
I have an image I want to display depending on a condition.

<% If  CONDITION   Then %>

<% End If  %>

What i need to check for is a field value from a recordset.

The object is: Contactdetails.contactstatus

Recordset = Contactdetails
Field = contactstatus

I want to display the image IF the value of the object is different from :  0, 1 or 2
0
Comment
Question by:amucinobluedot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 14

Expert Comment

by:R-Byter
ID: 34997760
<%
     select case Contactdetails("contactstatus")
          case 0
               Response.Write("0")
          case 1
               Response.Write("1")
          case 2
               Response.Write("2")
     end select
%>

Open in new window

0
 
LVL 33

Expert Comment

by:Big Monty
ID: 34997795
try this:

<%
status = contactDetails("contactDetails")
if Len( status ) > 0 and isNumeric( status ) then
   status = CInt( status )
   if status < 0 or status > 2 then
      Response.Write "<img src='pathToImage'/>"
end if
%>
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 34997802
sorry, the first line should be:

status = contactDetails("contactStatus")
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:amucinobluedot
ID: 34998516
Maybe i didnt explain myself, would be more something like:

<% If  NOT (contactDetails.contactstauts) = 0 or (contactDetails.contactstauts) = 1 or (contactDetails.contactstauts) = 2 Then %>

<% End If  %>

Just want to make sure that (contactDetails.contactstauts is different from ALL three values (0,1,2) THEN display whatever, else nothing, simply end, it wont display anything. Just need help with the syntax of that.
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 34998574
thats what my code example does. What I did is made the assumption that the contactStatus field will be a number (if it isnt, it wont do the check), then i check the number to make sure it isnt in the range of 0-2, if it isnt, it'll write out the image, otherwise it will do nothing.

Am I correct in my assumption in what you wanted accomplished?
0
 

Author Comment

by:amucinobluedot
ID: 34999012
Cant it be done with somehting like:

 <% If (ContactDetails.contactstauts = "0") OR (ContactDetails.contactstauts = "1") OR (ContactDetails.contactstauts = "2")  Then %>  

MY IMAGE

<% End If  %>

The above syntax is not correct though.
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 34999033
you can, just change your IF statement to:

<% If not (ContactDetails.contactstauts = "0") and not (ContactDetails.contactstauts = "1") and not (ContactDetails.contactstauts = "2")  Then %>  

this will display the image if the status doesnt equal 0,1, or 2
0
 

Author Comment

by:amucinobluedot
ID: 34999119
Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'contactstauts'

/BlueDot/Questionnaire/QnrPreview.asp, line 721
0
 
LVL 14

Expert Comment

by:R-Byter
ID: 34999148
Try this:

<% If (contactDetails("contactDetails") <> "0") and (contactDetails("contactDetails") <> "1") and (contactDetails("contactDetails")<> "2")  Then %>  

Open in new window


Regards
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question