Click to See Complete Forum and Search --> : Javascript - Type Mismatch getthedate


rosenzl
03-10-2003, 08:43 AM
I am trying to get a date returned to me with the following code. I am passing the function the value 0, so the function can return the first occurrence of the date created within the function.

Thanks

Below is in the had section
-------------------------------------------------------------------
<script language="JavaScript"><!--
function getthedate(dte) {
var now = new Date();
now = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0); // midnight

var text = '<form><select name=thedates>';
for (i=0; i<2; i++) {
var theDay = new Date(now.getTime()+(i*24*60*60*1000));
If (i == 0 && dte == 0); {
var theDay = new Date(now.getTime()+(i*24*60*60*1000));
dte += (theDay.getMonth()+1) + '/' + theDay.getDate() + '/' + theDay.getFullYear();

return dte;
}
}
}
//--></script>
----------------------------------------------------------------------
Below is in the head section following the function

<%
dim todaydate
todaydate = getthedate(0)
%>

khalidali63
03-10-2003, 09:01 AM
You had couple of syntactical errors..

here is the corrected function


function getthedate(dte) {
var now = new Date();
now = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0); // midnight

var text = '<form><select name=thedates>';
for (i=0; i<2; i++) {
var theDay = new Date(now.getTime()+(i*24*60*60*1000));
if (i == 0 && dte == 0) {
var theDay = new Date(now.getTime()+(i*24*60*60*1000));
dte += (theDay.getMonth()+1) + '/' + theDay.getDate() + '/' + theDay.getFullYear();

return dte;
}
}
}


Cheers

Khalid

rosenzl
03-10-2003, 09:28 AM
Khalid, I am still getting Type Mismatch. Could it be the way I am calling the function?


<%
dim todaydate
todaydate = getthedate(0)
%>