Solved

Display based on condition ASP/VB

Posted on 2011-02-28
9
270 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 32

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 32

Expert Comment

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

status = contactDetails("contactStatus")
0
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 32

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 32

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now