I have created a common JavaScript file which will be used for all the modules. It does the date validations for me. Whenever, a date is being entered it is being validated and if invalid it will prompt user to enter the correct the date.
If I keep the Javascript function in the ASP file it work. But now I have created a common Javascript function file and when I call the function in Javascript file from ASP, it gives me errors.
Look for TextDateFrom & TextDateTo.
How can u create a common function file and call this from ASP. It gives me an error at
<input id="txDateFrom" name="txtDateFrom" size="10" maxlength="10" value=<%=Date()-22%>
onFocus="javascript:vDateT
ype='3'" onKeyUp="DateFormat(this,t
his.value,
event,fals
e,'3')" onBlur="DateFormat(this,th
is.value,e
vent,true,
'3')">
My ASP modules is :
<HTML>
<HEAD>
<TITLE>Total Volumes processed by Each Site</TITLE>
<!-- #include file="adovbs.inc" -->
</HEAD>
<BODY BGCOLOR="#ffffff">
<SCRIPT language="JavaScript" src=DateValidation.js></SC
RIPT>
<%
dim objConn, ObjRS, sSQL, tempdate, datefrom, depot, dateto, dat1, dat2, origdat1
dim tempdateto, tempdatefrom, dd, origdd, status, name
dateto=CDate(Request.Form(
"txtdateTo
"))
If dateto=0 then
dateto=date()-19
datefrom=date()-22
tempdateto=dateto
tempdatefrom=datefrom
else
dateto=CDate(Request.Form(
"txtdateTo
"))
datefrom=CDate(Request.For
m("txtdate
From"))
tempdateto=dateto
tempdatefrom=datefrom
end if
name = "All Sites"
Session.LCID = 2057
orig1=CLng((right("00" & Day(datefrom),2) & "" & right("00" & Month(datefrom),2) & "" & Year(datefrom)))
dat1=CLng((right("00" & Day(datefrom),2) & "" & right("00" & Month(datefrom),2) & "" & Year(datefrom)))
dat2=CLng((right("00" & Day(dateto),2) & "" & right("00" & Month(dateto),2) & "" & Year(dateto)))
dd=CLng(right("00" & Day(datefrom),2))
origdd=CLng(right("00" & Day(datefrom),2))
set objConn = Server.CreateObject("ADODB
.Connectio
n")
objConn.Open "provider=sqloledb;data source=JRL002465;initial catalog=lokesh;user id=sa;password=;"
set ObjRS = Server.CreateObject("ADODB
.Recordset
")
set ObjRS.ActiveConnection = objConn
ObjRS.CursorType = adOpenStatic
ObjRS.CursorLocation = adUseClient
sSql="select distinct del_depot_code,count(*),da
te_urn_sca
n from masteretox where del_depot_code <>'A'" &_
"and date_urn_scan>=" &_
dat1 &_
"and date_urn_scan<=" &_
dat2 &_
"and bypassed<>'B'" &_
"group by del_depot_code, date_urn_scan order by del_depot_code, date_urn_scan"
ObjRS.Open sSql
set ObjR1 = Server.CreateObject("ADODB
.Recordset
")
set ObjR1.ActiveConnection = objConn
ObjR1.CursorType = adOpenStatic
ObjR1.CursorLocation = adUseClient
Dim sql
sql="Select * from sites order by site_name"
ObjR1.Open sql
Dim r, count, total
'r is an index variable for the for loops, count is the number of rows of data
total = objRS.RecordCount
count = ObjRS.Fields.Count - 1
Dim arrDel(100), arrVol(100), arrComp(100), arrHorDel(100), arrHorVol(100)
Dim arrHorTotVol(100), arrHorTotDel(100), arrHorTot(100), arrHorTotComp(100)
r = "0"
for r = 0 to count
arrDel(r) = 0
arrVol(r)=0
arrComp(r)=0
arrHorDel(r)=0
arrHorVol(r)=0
arrHorTot(r)=0
arrHorTotVol(r)=0
arrHorTotDel(r)=0
arrHorTotComp(r)=0
next
' start building the table
%>
<form name="formVolumes" method="post" action="Site.asp" onSubmit="return goSubmit();">
<table border="0" cellspacing="0" cellpadding="0" width="390" align="center">
<tr align="middle">
<td nowrap><IMG height=29 src="etos.gif" width=74 align=center></td>
</tr>
<tr><td><font size=2>
<%Response.Write "Date From : " &datefrom%> &nb
sp;
<%Response.Write "Date To : " & dateto%>
<%Response.Write "Site : " & name%>
</td></tr>
</table>
<TABLE border="2" cellspacing="0" cellpadding="1" bordercolor="#ccccff" align="Center">
<colgroup>
<col WIDTH="60">
<tr bgcolor='#ccccff'>
<td rowspan="2" height="44"><b>DCSite</b><
/td>
<%
while not (tempdatefrom>tempdateto)
%>
<td height="25" width='80'>
<p align="center">
<%=tempdatefrom%></td>
<%
tempdatefrom=tempdatefrom+
1
wend
%>
<td height="25">
<p align="center">Total</td>
</tr>
<tr bgcolor='#ccccff'>
<%
'Initialising again
tempdateto=dateto
tempdatefrom=datefrom
while not (tempdatefrom>tempdateto)
Response.Write "<TD><B>" & " Volumes " & "</TD></B>"
tempdatefrom=tempdatefrom+
1
wend
Response.Write "<TD><B>" & " Volumes " & "</TD></B>"
tempdatefrom=tempdatefrom+
1
Response.Write "</td></tr>"
%>
</colgroup>
<%
Status=""
while not ObjR1.EOF
Response.Write "<TR ALIGN=CENTER>"
tempdateto=dateto
tempdatefrom=datefrom
dd=origdd
dat1=CLng((dd & "" & right("00" & Month(datefrom),2) & "" & Year(datefrom)))
Response.Write "<TD>" & ObjR1(0) & "</TD>"
while (tempdatefrom<=tempdateto)
If ObjRS.BOF = False then
ObjRS.MoveFirst
End if
While Not ObjRS.EOF
If (ObjR1(1)=ObjRS(0)) then
If (ObjRS("date_urn_scan")=da
t1) then
Response.Write "<TD>" & ObjRS(1) & "</TD>"
arrDel(r)=arrDel(r)+ObjRS(
1)
Status="Y"
end if
end if
ObjRS.MoveNext
Wend
' Response.Write dat1
dd=dd+1
dat1=CLng((dd & "" & right("00" & Month(datefrom),2) & "" & Year(datefrom)))
tempdatefrom=tempdatefrom+
1
If (Status<>"Y") then
Response.Write "<TD>" & "-" & "</TD>"
else
Status="N"
end if
wend
'arrComp(r)=CDbl(arrVol(r)
/arrDel(r)
)
Response.Write "<TD><B>" & arrDel(r) & "</B></TD>"
Response.Write "</tr>"
arrDel(r)=0
arrVol(r)=0
arrComp(r)=0
'ObjRS.MoveFirst
ObjR1.MoveNext
Wend
Status=""
'Printing the Totals
tempdateto=dateto
tempdatefrom=datefrom
dd=origdd
dat1=CLng((dd & "" & right("00" & Month(datefrom),2) & "" & Year(datefrom)))
Response.Write "<TR ALIGN=CENTER bgcolor='#FF9999'>"
Response.Write "<TD>" & "Totals" & "</TD>"
while (tempdatefrom<=tempdateto)
If ObjRS.BOF = False then
ObjRS.MoveFirst
End if
While Not ObjRS.EOF
'ObjRS.MoveFirst
If (ObjRS("date_urn_scan")=da
t1) then
arrHorDel(r)=arrHorDel(r)+
ObjRS(1)
Status="Y"
end if
ObjRS.MoveNext
Wend
dd=dd+1
dat1=CLng((dd & "" & right("00" & Month(datefrom),2) & "" & Year(datefrom)))
tempdatefrom=tempdatefrom+
1
If (Status<>"Y") then
Response.Write "<TD>" & "-" & "</TD>"
else
Status="N"
Response.Write "<TD><B>" & arrHorDel(r) & "</B></TD>"
arrHorTotDel(r)=arrHorTotD
el(r)+arrH
orDel(r)
arrHorDel(r)=0
end if
wend
Response.Write "<TD><B>" & arrHorTotDel(r) & "</B></TD>"
Response.Write "</TR>"
'end if
'end if
%></THEAD>
<DIV></DIV></TABLE></TD></
TR></TABLE
>
<%
ObjRS.Close
set ObjRS = nothing
set objConn = nothing
%>
<table border="0" cellspacing="1" cellpadding="1" align="center" bordercolor="#ccccff">
<tr>
<td class="Label" nowrap align="left">Date From</td>
<td class="Label" nowrap align="left">Date To</td>
</tr>
<tr>
<td align="left">
<input id="txDateFrom" name="txtDateFrom" size="10" maxlength="10" value=<%=Date()-22%>
onFocus="javascript:vDateT
ype='3'" onKeyUp="DateFormat(this,t
his.value,
event,fals
e,'3')" onBlur="DateFormat(this,th
is.value,e
vent,true,
'3')">
</td>
<td align="left">
<input id="txtDateTo" name="txtDateTo" size="10" maxlength="10" value=<%=Date()-19%>
onFocus="javascript:vDateT
ype='3'" onKeyUp="DateFormat(this,t
his.value,
event,fals
e,'3')" onBlur="DateFormat(this,th
is.value,e
vent,true,
'3')">
</td>
<td>
<A href="#">
<IMG onclick="document.formVolu
mes.submit
();" src="cmdbtn_big_report_ove
r.gif" border=0 name=refresh>
</A></td>
</tr></table></form>
</BODY>
</HTML>