Is there a way with javascript?
I have a frontpage .asp page that returns the results of a query. Is it possible to have javascript do some dynamic formatting of the data? i.e. if the date is older than today, color the text red, or if the field contains a specified value, make it bold...?
PErickson87
04-10-2004, 10:29 PM
dito could you paste the asp code so we all know the variables?
Here's a frontpage test that I'm experimenting with. I'd like the javascript about 1/2 way down this page to change the color of the text in the EXPIRES data when the value equals today. The data in the field is in the format MM/DD/YYYY.
Thanks
<html>
<head>
</head>
<body>
<table width="100%" border="1">
<thead>
<tr>
<td><b>ITEM</b></td>
<td><b>PRODUCT</b></td>
<td><b>NOTES</b></td>
<td><b>EXPIRES</b></td>
</tr>
</thead>
<tbody>
<!--webbot bot="DatabaseRegionStart" startspan
s-columnnames="ITEM,PRODUCT,NOTES,EXPIRES" s-columntypes="200,200,200,135"
s-dataconnection="Tester_Scheduler" b-tableformat="TRUE"
b-menuformat="FALSE" s-menuchoice="ITEM" s-menuvalue="ITEM"
b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE"
b-listlabels="TRUE" b-listseparator="TRUE" i-ListFormat="0"
b-makeform="TRUE" s-recordsource
s-displaycolumns="ITEM,PRODUCT,NOTES,EXPIRES" s-criteria s-order
s-sql="SELECT * FROM T_FloorNotes" b-procedure="FALSE" clientside
SuggestedExt="asp" s-DefaultFields s-NoRecordsFound="No records returned."
i-MaxRecords="256" i-GroupSize="0" BOTID="0"
u-dblib="../_fpclass/fpdblib.inc" u-dbrgn1="../_fpclass/fpdbrgn1.inc"
u-dbrgn2="../_fpclass/fpdbrgn2.inc" tag="TBODY"
local_preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left" width="100%"><font color="#000000">Database Results regions will not preview unless this page is fetched from a Web server with a web browser. The following table row will repeat once for every record returned by the query.</font></td></tr>"
preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left" width="100%"><font color="#000000">This is the start of a Database Results region. The page must be fetched from a web server with a web browser to display correctly; the current web is stored on your local disk or network.</font></td></tr>"
b-WasTableFormat="TRUE" --><!--#include file="../_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT * FROM T_FloorNotes"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=4 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Tester_Scheduler"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="ITEM"
fp_sMenuValue="ITEM"
fp_iDisplayCols=4
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<%
if EXPIRES = New Date() then
clr = "FF0000"
Else
clr = "000000"
End if
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" i-CheckSum="61808" endspan -->
<tr>
<td><!--webbot bot="DatabaseResultColumn" startspan
s-columnnames="ITEM,PRODUCT,NOTES,EXPIRES" s-column="ITEM"
b-tableformat="TRUE" b-hasHTML="FALSE" clientside
local_preview="<font size="-1">&lt;&lt;</font>ITEM<font size="-1">&gt;&gt;</font>"
preview="<font size="-1">&lt;&lt;</font>ITEM<font size="-1">&gt;&gt;</font>" --><%=FP_FieldVal(fp_rs,"ITEM")%><!--webbot
bot="DatabaseResultColumn" i-CheckSum="1828" endspan -->
</td>
<td><!--webbot bot="DatabaseResultColumn" startspan
s-columnnames="ITEM,PRODUCT,NOTES,EXPIRES" s-column="PRODUCT"
b-tableformat="TRUE" b-hasHTML="FALSE" clientside
local_preview="<font size="-1">&lt;&lt;</font>PRODUCT<font size="-1">&gt;&gt;</font>"
preview="<font size="-1">&lt;&lt;</font>PRODUCT<font size="-1">&gt;&gt;</font>" --><%=FP_FieldVal(fp_rs,"PRODUCT")%><!--webbot
bot="DatabaseResultColumn" i-CheckSum="9702" endspan -->
</td>
<td><!--webbot bot="DatabaseResultColumn" startspan
s-columnnames="ITEM,PRODUCT,NOTES,EXPIRES" s-column="NOTES"
b-tableformat="TRUE" b-hasHTML="FALSE" clientside
local_preview="<font size="-1">&lt;&lt;</font>NOTES<font size="-1">&gt;&gt;</font>"
preview="<font size="-1">&lt;&lt;</font>NOTES<font size="-1">&gt;&gt;</font>" --><%=FP_FieldVal(fp_rs,"NOTES")%><!--webbot
bot="DatabaseResultColumn" i-CheckSum="4879" endspan -->
</td>
<td><!--webbot bot="DatabaseResultColumn" startspan
s-columnnames="ITEM,PRODUCT,NOTES,EXPIRES" s-column="EXPIRES"
b-tableformat="TRUE" b-hasHTML="FALSE" clientside
local_preview="<font size="-1">&lt;&lt;</font>EXPIRES<font size="-1">&gt;&gt;</font>"
preview="<font size="-1">&lt;&lt;</font>EXPIRES<font size="-1">&gt;&gt;</font>" --><%=clr%>'><%=FP_FieldVal(fp_rs,"EXPIRES")%><!--webbot
bot="DatabaseResultColumn" i-CheckSum="9765" endspan -->
</td>
</tr>
<!--webbot bot="DatabaseRegionEnd" startspan b-tableformat="TRUE"
b-menuformat="FALSE" u-dbrgn2="../_fpclass/fpdbrgn2.inc" i-groupsize="0"
clientside tag="TBODY"
local_preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left" width="100%"><font color="#000000">This is the end of a Database Results region.</font></td></tr>"
preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left" width="100%"><font color="#000000">This is the end of a Database Results region.</font></td></tr>" --><!--#include file="../_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="DatabaseRegionEnd" i-CheckSum="56926" endspan -->
</tbody>
</table>
</body>
</html>
PErickson87
04-11-2004, 12:00 AM
I'm not entirely sure how to encorporate the JavaScript with the rest of the coding... but here's the code to put today's date into that format for anyone who does know:
<script>
var time=new Date();
var lmonth=time.getMonth()+1;
if (lmonth < 10) {lmonth='0'+lmonth;}
var date=time.getDate();
if (date < 10) {date='0'+date;}
var year=time.getYear();
today=lmonth+'/'+date+'/'+year;
</script>
I would imagine it would have to be written like:
var expireDate="<%=FP_FieldVal(fp_rs,"EXPIRES")%>";
if (expireDate == today) {
document.write('<font color=ff0000><b><%=FP_FieldVal(fp_rs,"EXPIRES")%></b></font>');
}
else {
document.write('<%=FP_FieldVal(fp_rs,"EXPIRES")%>');
}
Something like that. Good luck.