?
Solved

Change color with IF ELSE logic

Posted on 2011-10-21
3
Medium Priority
?
210 Views
Last Modified: 2012-08-13
Hi all

Given the code below
I need a way to change the color of the value outputed
<td><%=varStatus%></td>      

Depending on the record set value coming out of the database
rs_custInfo("SupportStatus")

the record set can have only 3 values Finish, WorkinProgress, Open

How can I re-write the code below to achive this..
at the moment I have only black color regardless of the value in the database
<tr>
	<td ><strong><%=txt(009)%></strong></td>						
	<% If (rs_custInfo("SupportStatus") = "Finish" ) then %>
		<td><span class="auto-green"><%=varStatus%></span></td>	
	<%ElseIf (rs_custInfo("SupportStatus") = "WorkinProgress") then %>
		<td><span class="auto-red"><%=varStatus%></span></td>
	<%else%>						
		<td><%=varStatus%></td>							
	<% End If %>														
</tr>

Open in new window

0
Comment
Question by:ZURINET
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 800 total points
ID: 37005468
please do your coding like this:
<tr>
  <td ><strong><%=txt(009)%></strong></td>
<% 
   v_span = "<span "
   if rs_custInfo("SupportStatus") = "Finish" ) then
      v_span = v_span & "class=""auto-green"""
   end if
   if rs_custInfo("SupportStatus") = "WorkinProgress" ) then
      v_span = v_span & "class=""auto-red"""
   end if

   v_span = vspan & ">" & varStatus & "<(span>"
%>
  <td><%=v_span%></td> 
                      
</tr>

Open in new window

0
 
LVL 9

Assisted Solution

by:keyu
keyu earned 600 total points
ID: 37005523
hi,

try this

<tr>
      <td ><strong><%=txt(009)%></strong></td>                                    
<%
If (rs_custInfo("SupportStatus") = "Finish" ) then
stylevar="Class='auto-green'"
ElseIf (rs_custInfo("SupportStatus") = "WorkinProgress") then
stylevar="Class='auto-blue'"
else
stylevar=" "
End If

%>                                          
                               <td><span <%=stylevar%>><%=varStatus%></span></td>                                          
</tr>
0
 
LVL 8

Assisted Solution

by:jawa29
jawa29 earned 600 total points
ID: 37005795
Hi

Here is another way to achieve this, make sure your styles are working correctly first by placing them on a static item first (just to test).
<%
varStatus = rs_custInfo("SupportStatus")

Select Case varStatus
	Case Finish
		varStyle = "class=""auto-green"""
	Case WokinProgress
		varStyle = "class=""auto-red"""
	Case Else
		varStyle = ""
End Select
%>
<tr>
	<td><strong><%= txt(000) %></strong></td>
	<td><span <%= varStyle %>><%= varStatus %></span></td>
</tr>

Open in new window

Jawa29
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

621 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