Menu
I have a drop down box and a dinamic table. When you make a selection it populates the table with number data. Now what I am trying to figure is how can I have certain items returned be a diffrent color if certain conditions are met. For example I want the highest number returned to be red. How can I do this? Thanks in advance
[CODE]<form id="form1" name="form1" method="get" action="">
<label></label>
<label></label>
<div align="center">
<p>
<select name="DATE12">
<option value="Select Date">Select Date</option>
<option value="1/1/2008">01/01/2008</option>
<option value="1/2/2008">01/02/2008</option>
<option value="1/3/2008">01/03/2008</option>
<option value="1/4/2008">01/04/2008</option>
<option value="1/5/2008">01/05/2008</option>
<option value="1/6/2008">01/06/2008</option>
<option value="1/7/2008">01/07/2008</option>
<option value="1/8/2008">01/08/2008</option>
<option value="1/9/2008">01/09/2008</option>
<option value="1/10/2008">01/10/2008</option>
<option value="1/11/2008">1/11/2008</option>
while (!Recordset1.EOF) {
%><option value="<%=(Recordset1.Fields.Item("DATE12").Value)%>"><%=(Recordset1.Fields.Item("DATE12").Value)%></option>
<%
Recordset1.MoveNext();
}
if (Recordset1.CursorType > 0) {
if (!Recordset1.BOF) Recordset1.MoveFirst();
} else {
Recordset1.Requery();
}
%>
</select>
<input type="submit" name="Submit" value="Submit" />
</p>
</div>
<table border="1" cellpadding="0" cellspacing="0">
<tr bgcolor="#FFFFFF">
<td colspan="2"><div align="center"><strong>Application Peak Including
Slippage</strong></div> <div align="center"></div></td>
<td bgcolor="#66CC66"><div align="center"><span class="style4"><%=(Recordset2.Fields.Item("APP1PEAK").Value)%></span></div></td>
<td bgcolor="#66CC66"><div align="center"><span class="style4"><%=(Recordset3.Fields.Item("APP5PEAK").Value)%></span></div></td>
<td bgcolor="#66CC66"><div align="center"><span class="style4"><%=(Recordset4.Fields.Item("APP6PEAK").Value)%></span></div></td>
<td bgcolor="#66CC66"><div align="center"><span class="style4"><%=(Recordset5.Fields.Item("APP10PEAK").Value)%></span></div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset6.Fields.Item("APP11PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset7.Fields.Item("APP20PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset8.Fields.Item("APP21PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset9.Fields.Item("APP95PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset10.Fields.Item("APP100PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset11.Fields.Item("APP101PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset12.Fields.Item("APP102PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center"><span class="style2"><strong><%=(Recordset13.Fields.Item("APP110PEAK").Value)%></strong></span></div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset14.Fields.Item("APP231PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset15.Fields.Item("APP123PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset16.Fields.Item("APP125PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset17.Fields.Item("APP135PEAK").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset18.Fields.Item("APP137PEAK").Value)%></div>
</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="145"><div align="center" class="style2">
<div align="center"><strong>Date</strong></div>
</div></td>
<td width="119"><div align="center" class="style2">
<div align="center"><strong>Time</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>1</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>5</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>6</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>10</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>11</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>20</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>21</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>95</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>100</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>101</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>102</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>110</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>231</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>123</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>125</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>135</strong></div>
</div></td>
<td width="140"><div align="center" class="style2">
<div align="center"><strong>137</strong></div>
</div></td>
</tr>
<% while ((Repeat1__numRows-- != 0) && (!Recordset1.EOF)) { %>
<tr bgcolor="#999999">
<td bgcolor="#FFFFFF"><div align="center"><span class="style4"><%=(Recordset1.Fields.Item("DATE12").Value)%></span></div></td>
<td bgcolor="#33CC00"><div align="center"><strong><span class="style5"><%=(Recordset1.Fields.Item("Time").Value)%></span></strong></div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App001").Value)%></div>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App100").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App101").Value)%></div>
</div></td>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App102").Value)%></div>
<td bgcolor="#66CC66"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App137").Value)%></div>
</div></td>
</tr>
<%
Repeat1__index++;
Recordset1.MoveNext();
}
%>
</table>
</p>
</form>
</body>
</html>
<%
Recordset1.Close();[/CODE]
[CODE] <% while ((Repeat1__numRows-- != 0) && (!Recordset1.EOF)) { %>
<tr bgcolor="#999999">
<td bgcolor="#FFFFFF"><div align="center"><span class="style4"><%=(Recordset1.Fields.Item("DATE12").Value)%></span></div></td>
<td bgcolor="#33CC00"><div align="center"><strong><span class="style5"><%=(Recordset1.Fields.Item("Time").Value)%></span></strong></div></td>
<td bgcolor="#66CC66" id="App1"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App001").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App5"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App005").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App6"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App006").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App10"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App010").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App11"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App011").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App20"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App020").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App21"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App021").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App95"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App095").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App100"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App100").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App101"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App101").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App102"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App102").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App110"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App110").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App231"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App231").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App123"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App123").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App125"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App125").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App135"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App135").Value)%></div>
</div></td>
<td bgcolor="#66CC66" id="App137"><div align="center" class="style4">
<div align="center"><%=(Recordset1.Fields.Item("App137").Value)%></div>
</div></td>[/CODE]
[CODE]<script type="text/javascript">
<!--
function Lightup() {
var obj=document.forms["form1"];
for (i=0;i<obj.length;i++) {
with (obj[i]) {
if (document.getElementById('App1') = "2") {
document.getElementById('App1').style.backgroundColor='#DBF18A';
}
}
}
}
//-->
</script> [/CODE]
am I getting closer? Yeah yeah I suck at code im trying<html>
<head>
<script language = "javascript">
defaultColor = '#eeeeee';
maxValueColor = '#ff0000';
function highlightMax(tableID, column) {
var maxValue = 0;
if (!document.all || !document.getElementById) { return; }
tableObj = document.getElementById(tableID);
tableBody = tableObj.childNodes[0];
//Iterrate through each row
for (i=1; i<tableBody.childNodes.length; i++) {
//Create row object
tableRow = tableBody.childNodes[i];
//Check if it is a table row
if (tableRow.nodeName == "TR") {
//Create cell object
tableCell = tableRow.childNodes[column];
//Check if the object is a table cell
if (tableCell.nodeName == "TD") {
//Get the value of the cell from the column parameter
cellValue = parseFloat(tableCell.innerHTML);
//Set maxValue to new value if greater than maxValue
maxValue = (cellValue>maxValue)?cellValue:maxValue;
}
}
}
//Iterrate through each row again setting the BG color
for (i=1; i<tableBody.childNodes.length; i++) {
//Create row object
tableRow = tableBody.childNodes[i];
//Check if it is a table row
if (tableRow.nodeName == "TR") {
//Create cell object
tableCell = tableRow.childNodes[column];
//Check if the object is a table cell
if (tableCell.nodeName == "TD") {
//Get the value of the cell from the column parameter
cellValue = parseFloat(tableCell.innerHTML);
tableCell.style.backgroundColor = (cellValue==maxValue) ? maxValueColor : defaultColor;
}
}
}
}
</script>
</head>
<body>
<table cellspacing="0" cellpadding="5" border="1" id="myGrid">
<tr style="color:White;background-color:#336699;font-weight:bold;">
<td>First Name</td><td>Last Name</td><td>Email</td><td>Amt</td>
</tr>
<tr style="background-color: #eeeeee;">
<td>Bugs</td><td>Bunny</td><td>[email protected]</td><td>5</td>
</tr>
<tr style="background-color: #eeeeee;">
<td>Mickey</td><td>Mouse</td><td>[email protected]</td><td>4</td>
</tr>
<tr style="background-color: #eeeeee;">
<td>Donald</td><td>Duck</td><td>[email protected]</td><td>8</td>
</tr>
<tr style="background-color: #eeeeee;">
<td>Dan</td><td>Marino</td><td>[email protected]</td><td>3</td>
</tr>
<tr style="background-color: #eeeeee;">
<td>Steve</td><td>Stchur</td><td>[email protected]</td><td>6</td>
</tr>
</table>
<input type="button" onclick="highlightMax('myGrid', 3);" value="Button">
</body>
</html>
0.1.9 — BETA 5.18