Change color with IF ELSE logic

Posted on 2011-10-21
Last Modified: 2012-08-13
Hi all

Given the code below
I need a way to change the color of the value outputed

Depending on the record set value coming out of the database

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
	<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>
	<% End If %>														

Open in new window

Question by:ZURINET
    LVL 142

    Accepted Solution

    please do your coding like this:
      <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>"

    Open in new window

    LVL 9

    Assisted Solution


    try this

          <td ><strong><%=txt(009)%></strong></td>                                    
    If (rs_custInfo("SupportStatus") = "Finish" ) then
    ElseIf (rs_custInfo("SupportStatus") = "WorkinProgress") then
    stylevar=" "
    End If

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

    Assisted Solution


    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
    	<td><strong><%= txt(000) %></strong></td>
    	<td><span <%= varStyle %>><%= varStatus %></span></td>

    Open in new window


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
    The viewer will learn how to count occurrences of each item in an array.

    728 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

    21 Experts available now in Live!

    Get 1:1 Help Now