Forums
This topic is locked
Conditional CSS Style
22 May 2006 10:55:13 jason Sum posted:
Hi Just wonder if any one know how to solve thisWhat i am trying to achive is in my database i have a filed call feature and the table is product.
i want to write a css would control the back ground colour of the display page
say if feature is = yes then on the display page would have yellow back ground.
if is not = yes then
<%DIM iRecordCount
iRecordCount = 0
While ((Repeat1__numRows <> 0) AND (NOT Jason.EOF))
IF iRecordCount Mod 2 = 0 THEN
%><table width="542" border="0" cellpadding="0" cellspacing="0" id="one">
<tr bgcolor="#FFFFFF">
<td width="203" ><%=(Jason.Fields.Item("ItemTitle".Value)%></td>
<td width="239"><%=(Jason.Fields.Item("ItemInfo".Value)%></td>
<td width="100"><%=(Jason.Fields.Item("ItemBuyNow".Value)%></td>
</tr>
<% Else %>
<tr bgcolor="#CCCCCC">
<td ><%=(Jason.Fields.Item("ItemTitle".Value)%></td>
<td><%=(Jason.Fields.Item("ItemInfo".Value)%></td>
<td><%=(Jason.Fields.Item("ItemBuyNow".Value)%></td>
</tr>
</table>
<% END IF
iRecordCount = iRecordCount + 1
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Jason.MoveNext()
Wend%>
Replies
Replied 22 May 2006 17:57:46
22 May 2006 17:57:46 micah santos replied:
this should be in your looping statement
<%
Dim strBgcolor
If strBgcolor = "#FFFFFF" Then
strBgcolor = "#000000"
Else
strBgcolor = "FFFFFF"
End If
%>
<tr bgcolor="<%=strBgcolor%>">
<td>
</td>
</tr>
<%
Dim strBgcolor
If strBgcolor = "#FFFFFF" Then
strBgcolor = "#000000"
Else
strBgcolor = "FFFFFF"
End If
%>
<tr bgcolor="<%=strBgcolor%>">
<td>
</td>
</tr>
Replied 23 May 2006 03:48:20
23 May 2006 03:48:20 jason Sum replied:
Hi micah
The code you provide has nothing to do with my database.
how would i show say a yellow colour, if data = yes.
else.
will write and alternative colour.
The code you provide has nothing to do with my database.
how would i show say a yellow colour, if data = yes.
else.
will write and alternative colour.
Replied 23 May 2006 15:32:22
23 May 2006 15:32:22 jason Sum replied:
Hi micah
can you see any error in here..
it doesn't seem to work.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/conn.asp" -->
<%
Dim feature
Dim feature_numRows
Set feature = Server.CreateObject("ADODB.Recordset"
feature.ActiveConnection = MM_conn_STRING
feature.Source = "SELECT * FROM Product"
feature.CursorType = 0
feature.CursorLocation = 2
feature.LockType = 1
feature.Open()
feature_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
feature_numRows = feature_numRows + Repeat1__numRows
%>
<%
Dim strBgcolor
If strBgcolor = (feature.Fields.Item("ItemSubMain".Value)="yes" Then
strBgcolor = "#000000"
Else
strBgcolor = "#FFFFFF"
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
</head>
<body>
<table width="542" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="46"><%
While ((Repeat1__numRows <> 0) AND (NOT feature.EOF))
%>
<table width="542" border="0" cellspacing="1" cellpadding="1">
<tr bgcolor ="<%=strBgcolor%>">
<td width="232"><%=(feature.Fields.Item("ItemTitle".Value)%></td>
<td width="151"><%=(feature.Fields.Item("ItemInfo".Value)%></td>
<td width="151"><%=(feature.Fields.Item("ItemSubMain".Value)%></td>
</tr>
</table>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
feature.MoveNext()
Wend
%></td>
</tr>
</table>
</body>
</html>
<%
feature.Close()
Set feature = Nothing
%>
can you see any error in here..
it doesn't seem to work.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/conn.asp" -->
<%
Dim feature
Dim feature_numRows
Set feature = Server.CreateObject("ADODB.Recordset"
feature.ActiveConnection = MM_conn_STRING
feature.Source = "SELECT * FROM Product"
feature.CursorType = 0
feature.CursorLocation = 2
feature.LockType = 1
feature.Open()
feature_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
feature_numRows = feature_numRows + Repeat1__numRows
%>
<%
Dim strBgcolor
If strBgcolor = (feature.Fields.Item("ItemSubMain".Value)="yes" Then
strBgcolor = "#000000"
Else
strBgcolor = "#FFFFFF"
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
</head>
<body>
<table width="542" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="46"><%
While ((Repeat1__numRows <> 0) AND (NOT feature.EOF))
%>
<table width="542" border="0" cellspacing="1" cellpadding="1">
<tr bgcolor ="<%=strBgcolor%>">
<td width="232"><%=(feature.Fields.Item("ItemTitle".Value)%></td>
<td width="151"><%=(feature.Fields.Item("ItemInfo".Value)%></td>
<td width="151"><%=(feature.Fields.Item("ItemSubMain".Value)%></td>
</tr>
</table>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
feature.MoveNext()
Wend
%></td>
</tr>
</table>
</body>
</html>
<%
feature.Close()
Set feature = Nothing
%>
Replied 23 May 2006 15:51:11
23 May 2006 15:51:11 micah santos replied:
<%
Dim strBgcolor
If (feature.Fields.Item("ItemSubMain".Value)="yes" Then
strBgcolor = "#000000"
Else
strBgcolor = "#FFFFFF"
End If
%>
Dim strBgcolor
If (feature.Fields.Item("ItemSubMain".Value)="yes" Then
strBgcolor = "#000000"
Else
strBgcolor = "#FFFFFF"
End If
%>
Replied 23 May 2006 20:51:35
23 May 2006 20:51:35 jason Sum replied:
Thanks for that.
sorry i have another question
can you see any thing wrong with the following code..
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/conn.asp" -->
<%
Dim feature
Dim feature_numRows
Set feature = Server.CreateObject("ADODB.Recordset"
feature.ActiveConnection = MM_conn_STRING
feature.Source = "SELECT * FROM Product"
feature.CursorType = 0
feature.CursorLocation = 2
feature.LockType = 1
feature.Open()
feature_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
feature_numRows = feature_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
</head>
<body>
<%DIM iRecordCount
iRecordCount = 0
While ((Repeat1__numRows <> 0) AND (NOT feature.EOF))
Dim strBgcolor
If (feature.Fields.Item("ItemSubMain".Value)="yes" Then
strBgcolor = "#FFFF66"
Else
strBgcolor = ""
End If
IF iRecordCount Mod 2 = 0 THEN
%>
<table width="542" border="0" cellspacing="1" cellpadding="1">
<tr bgcolor="#CCCCCC">
<td width="147" bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemTitle".Value)%></td>
<td width="279" bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemInfo".Value)%></td>
<td width="106" bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemBuyNow".Value)%></td>
</tr>
<tr bgcolor="#FFFFFF">
<td bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemTitle".Value)%></td>
<td bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemInfo".Value)%></td>
<td bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemBuyNow".Value)%></td>
</tr>
</table>
<% END IF
iRecordCount = iRecordCount + 1
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
feature.MoveNext()
Wend%></body>
</html>
<%
feature.Close()
Set feature = Nothing
%>
sorry i have another question
can you see any thing wrong with the following code..
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/conn.asp" -->
<%
Dim feature
Dim feature_numRows
Set feature = Server.CreateObject("ADODB.Recordset"
feature.ActiveConnection = MM_conn_STRING
feature.Source = "SELECT * FROM Product"
feature.CursorType = 0
feature.CursorLocation = 2
feature.LockType = 1
feature.Open()
feature_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
feature_numRows = feature_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
</head>
<body>
<%DIM iRecordCount
iRecordCount = 0
While ((Repeat1__numRows <> 0) AND (NOT feature.EOF))
Dim strBgcolor
If (feature.Fields.Item("ItemSubMain".Value)="yes" Then
strBgcolor = "#FFFF66"
Else
strBgcolor = ""
End If
IF iRecordCount Mod 2 = 0 THEN
%>
<table width="542" border="0" cellspacing="1" cellpadding="1">
<tr bgcolor="#CCCCCC">
<td width="147" bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemTitle".Value)%></td>
<td width="279" bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemInfo".Value)%></td>
<td width="106" bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemBuyNow".Value)%></td>
</tr>
<tr bgcolor="#FFFFFF">
<td bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemTitle".Value)%></td>
<td bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemInfo".Value)%></td>
<td bgcolor="<%= strBgcolor%>"><%=(feature.Fields.Item("ItemBuyNow".Value)%></td>
</tr>
</table>
<% END IF
iRecordCount = iRecordCount + 1
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
feature.MoveNext()
Wend%></body>
</html>
<%
feature.Close()
Set feature = Nothing
%>
Replied 23 May 2006 20:54:08
23 May 2006 20:54:08 jason Sum replied:
sorry i got it sorted.. just forgot to put <%else%> stupid me..
thanks for your help
thanks for your help