switch case statment to set a CSS class style variable

Discussion in 'JavaScript' started by thewackonerd, May 2, 2005.

  1. #1
    Hi All
    I am trying to allow, via the admin section, the ability to change the background colours of a table.
    The problems I am having is as follows;
    - I have 4 of these sections on a dynamic template page
    - not all the sections are used each time the template is called
    - I want to either make the colours default to a specific colour if used or if not used, then to display a set colour

    I see 2 ways for this to happen;
    1 - if statements for the colours
    - or -
    2 - SQL statement to disallow the table to be shown unless content is posted in the database

    I am new to SQL and 'if' statements.
    I am using dreamweaver MX 2004 with access 2000.

    This is the code I want to be able to hide, I have 4 of these section on a page.

    I believe that a switch case statment to set a CSS class style variable is the way to go but I am a bit thick and dont pick these things up quickly, your help would be invaluable.

    ------------------------------------------------------------------------------------------------
    <table width="150" border="0" cellpadding="1" cellspacing="0" bgcolor="#<%=(rs_pages.Fields.Item("S_SideHeading4_ColourBG").Value)%>">
                <tr>
                  <td>
                <table width="150"  border="0" cellspacing="0" cellpadding="4">
                      <tr>
                        <td align="center" bgcolor="#<%=(rs_pages.Fields.Item("S_SideHeading4_ColourBG").Value)%>"><strong><%=(rs_pages.Fields.Item("S_SideHeading4").Value)%></strong></td>
                      </tr>
                      <tr>
                        <td bgcolor="#<%=(rs_pages.Fields.Item("S_SideContent4_ColourBG").Value)%>">
                <%Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
    			objFile = Request.ServerVariables("SCRIPT_NAME")
    			ImagePath = Server.MapPath("../site_images\")
    			ImagePath = ImagePath & "\" & (rs_pages.Fields.Item("S_SideImage4").Value)
    			If objFileSystem.FileExists(ImagePath) then%>
                <img src="../site_images/<%=(rs_pages.Fields.Item("S_SideImage4").Value)%>"  border="0" align="right" /><%=(rs_pages.Fields.Item("S_SideHeading4").Value)%> 
                <%End If%>
                
                <%= CI_Preserve((rs_pages.Fields.Item("S_SideContent4").Value)) %>
                        </td>
                      </tr>
                  </table>
          </td>
        </tr>
    </table>
    Code (markup):
     
    thewackonerd, May 2, 2005 IP