Solved

Display based on condition ASP/VB

Posted on 2011-02-28
9
273 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
  • 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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