Stefan Motz
asked on
If statement in Classic ASP
Hi Experts,
<%=rs("EmpStatus")%> can display 3 values on my page:
A
I
T
These stand for Active, Inactive, and Terminated.
How could I display the actual words instead of the abbreviation with the help of an If statement?
Thank you for your help.
<%=rs("EmpStatus")%> can display 3 values on my page:
A
I
T
These stand for Active, Inactive, and Terminated.
How could I display the actual words instead of the abbreviation with the help of an If statement?
Thank you for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much, it's perfect. Both solutions worked.
You might want to put the code earlier in the page and leave a simple result inline.
If rs("EmpStatus") = 'A' Then reEmpstatus = "Active"
If rs("EmpStatus") = 'I' Then reEmpstatus = "Inactive"
If rs("EmpStatus") = 'T' Then reEmpstatus = "Terminated"
Then later you would use..
<%=rsEmpStatus%>
Oops... had to answer a phone call while I was typing.
Big Monty is faster at answering but this is a great alternative. No if/then and you can easily reuse.
' place towards the top of your page
<%
Dim iStatus
Set iStatus=Server.CreateObject("Scripting.Dictionary")
iStatus.Add "A","Active"
iStatus.Add "I","Inactive"
iStatus.Add "T","Terminated"
%>
<ul>
<%
do until rs.eof
' Where you need it in your page
'Response.Write "This should print out Active: " & iStatus.Item("A")
response.write "<li>Status:"&iStatusItem(rs("EmpStatus"))&"</li>"
rs.move.next
loop
%>
</ul>
For more info on the dictionary object http://www.w3schools.com/asp/asp_ref_dictionary.asp
ASKER
Thank you very much all of you.
Padas, I like your alternative; I will use it in the future.
Padas, I like your alternative; I will use it in the future.
Open in new window