Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Display based on condition ASP/VB

Posted on 2011-02-28
9
Medium Priority
?
302 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:Aleks
  • 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 34

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 34

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:Aleks
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 34

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:Aleks
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 34

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:Aleks
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

971 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