Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Display based on condition ASP/VB

Posted on 2011-02-28
9
Medium Priority
?
280 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
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!

 

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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 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