Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a calendar 1

Status
Not open for further replies.

neillovell

Programmer
Aug 27, 2002
560
GB
Hi,
in MS Access I used an activeX control I think to create a calendar on a form (you clicked a combo-box down arrow and it appeared). Now that I've saved the form as a data access page it does not work - nothing appears.

Does anyone have a bit of code to create a calendar? It's just so users can see what date monday is etc.
 
That calendar works great, EXCEPT I cannot use it on a page with a lot going on. What I mean is by itself, or with a basic timer function is fine. But if I try to put it on my main page with fields to fill in etc. I get unknown errors.

Also, it won't work in Netscape but it will in IE (because of a weird syntax thing - /rect// not sure what that's about.

Any other examples?
 
well maybe you could show us the page with the problem and I could tell you how to fix it. I used this calendar in an e-billing application with loads of javascript (about 100k) and had no problem. some of the forms on some pages had up to 300 elements.

If you can show us the page with the problem surely we can figure it out for you. Gary Haran
 
Ok here is the code. The calendar form call is at the bottom, the calendar set of functions are all together between two //*** markers

The culprit code (where the unknown run time error comes from) is this chunk


//*** This chunk is the culprit
var _divs = new Array();
var _calDivId;
var _calField;
var _calFieldMs;
function getCalendarFor(field, id, fieldMs)
{
_calField = field;
_calFieldMs = fieldMs;
_calDivId = id;
var div = Div(_calDivId);
div.innerHTML = new Date().getHtml();
div.setAsBlock();
}






<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>

<!DOCTYPE HTML
PUBLIC &quot;-//W3C//DTD/ XHTML 1.0
Transitional//EN&quot;
&quot; xhtml1-transitional.dtd&quot;>
<html xmlns=&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;>

<!-- Document Type Definition (DTD). A DTD essentially specifies what a document can and cannot

contain. -->


<HEAD><TITLE>Timesheet</TITLE>

<!-- Link in the stylesheet in the local directory. An alternative would be to use the @import

url(&quot; if the style sheet was on a web server somewhere.

-->
<link rel=&quot;stylesheet&quot;
type=&quot;text/css&quot;
href=&quot;TimesheetStyleSheet.css&quot; />


<SCRIPT LANGUAGE=Javascript>



//*** The Calendar set of functions


function show(id){ Div(id).show() }
function hide(id){ Div(id).hide() }
function displayAsBlock(id){ Div(id).setAsBlock() }
function displayAsNone(id){ Div(id).setAsNone() }

var _dom = (document.getElementById);
var _def = (document.defaultView);
var _ie = ((document.all && !_dom));
var _moz = (window.sidebar)
var language = (navigator.language ? navigator.language :

navigator.userLanguage).substring(0,2);
var undefined;


var monthNames,dayNames,shortDayNames;
switch (language)
{
case &quot;fr&quot; :
monthNames =

[&quot;Janvier&quot;,&quot;Fevrier&quot;,&quot;Mars&quot;,&quot;Avril&quot;,&quot;Mai&quot;,&quot;Juin&quot;,&quot;Juillet&quot;,&quot;Aout&quot;,&quot;Septembre&quot;,&quot;Octobre&quot;,&quot;Novembr

e&quot;,&quot;Decembre&quot;];
dayNames = [&quot;Dimanche&quot;,&quot;Lundi&quot;,&quot;Mardi&quot;,&quot;Mercredi&quot;,&quot;Jeudi&quot;,&quot;Vendredi&quot;,&quot;Samedi&quot;];
shortDayNames = [&quot;Dim&quot;,&quot;Lun&quot;,&quot;Mar&quot;,&quot;Mer&quot;,&quot;Jeu&quot;,&quot;Ven&quot;,&quot;Sam&quot;];
break;
default :
monthNames =

[&quot;January&quot;,&quot;February&quot;,&quot;March&quot;,&quot;April&quot;,&quot;May&quot;,&quot;June&quot;,&quot;July&quot;,&quot;August&quot;,&quot;September&quot;,&quot;October&quot;,&quot;Novemb

er&quot;,&quot;December&quot;];
dayNames = [&quot;Sunday&quot;,&quot;Monday&quot;,&quot;Tuesday&quot;,&quot;Wednesday&quot;,&quot;Thursday&quot;,&quot;Friday&quot;,&quot;Saturday&quot;];
shortDayNames = [&quot;Sun&quot;,&quot;Mon&quot;,&quot;Tue&quot;,&quot;Wed&quot;,&quot;Thu&quot;,&quot;Fri&quot;,&quot;Sat&quot;];
}

Date.prototype.getMonthName = function(){ return monthNames[this.getMonth()] }
Date.prototype.getDayName = function(){ return dayNames[this.getDay()] }

Date.prototype.getHumanTime = function()
{
var minutes = this.getMinutes();
return this.getHours() + &quot;:&quot; + (minutes > 9 ? minutes : &quot;0&quot; + minutes);
}

Date.prototype.getDaysInMonth = function()
{
return [31,(this.isLeap() ? 29 : 28),31,30,31,30,31,31,30,31,30,31][this.getMonth()];
}

Date.prototype.isLeap = function()
{
var year = this.getFullYear();
return ( (year % 4) && (year % 100) || !(year % 400) );
}

Date.prototype.getMonthStartDay = function()
{
var date = this;
date.setDate(1);
return date.getDay();
}

Date.prototype.getYearStartDay = function()
{
var date = this;
date.setDate(1);
date.setMonth(0);
return date.getMonthStartDay();
}

Date.prototype.getWorkingWeek = function()
{
var yearReference = new Date(this.getFullYear(), 0, 0);
var yearInMills = yearReference.getTime() + (yearReference.getYearStartDay() * 24 * 60 * 60);
return (Math.ceil(Math.abs(yearInMills - this.getTime()) / ((1000 * 60 * 60 * 24 * 7) -

yearReference.getYearStartDay())));
}

Date.prototype.getDaysInBetween = function(date)
{
return Math.abs(this.getTime() - date.getTime());
}

Date.prototype.getHtml = function(element)
{
var startDay = this.getMonthStartDay();
var month = this.getMonth();
var year = this.getFullYear();
var daysTotal = this.getDaysInMonth();
var cols = 7;

var output = &quot;<table cellpadding=3 cellspacing=0 border=0 class=calTable bgcolor=white>&quot;
+ &quot;<tr>&quot;;

var mouseStr = &quot; align=center valign=center class=selOff&quot;
+ &quot; onmouseover=\&quot;this.className='selOver'\&quot;&quot;
+ &quot; onmouseout=\&quot;this.className='selOff'\&quot;&quot;;

// month and year select boxes.
output += &quot;<td colspan=&quot; + cols + &quot; class=calSelect>&quot;
+ &quot;<table width=100%>\n&quot;
+ &quot;<tr>\n&quot;
+ &quot;<td&quot; + mouseStr + &quot; onclick=\&quot;if(typeof onCalendarChange == 'function'){&quot;
+ &quot;onCalendarChange(new Date(&quot; + (year - 1) + &quot;,&quot; + month + &quot;))}else&quot;
+ &quot;{defaultCalendarChange(new Date(&quot; + (year - 1) + &quot;,&quot; + month +

&quot;))}\&quot;>\n<<</td>\n&quot;
+ &quot;<td&quot; + mouseStr + &quot; onclick=\&quot;if(typeof onCalendarChange == 'function'){&quot;
+ &quot;onCalendarChange(new Date(&quot; + year + &quot;,&quot; + (month - 1) + &quot;))}else&quot;
+ &quot;{defaultCalendarChange(new Date(&quot; + year + &quot;,&quot; + (month - 1) +

&quot;))}\&quot;>\n<</td>\n&quot;
+ &quot;<td align=center>&quot; + this.getMonthName() + &quot; &quot; + year + &quot;</td>&quot;
+ &quot;<td&quot; + mouseStr + &quot; onclick=\&quot;if(typeof onCalendarChange == 'function'){&quot;
+ &quot;onCalendarChange(new Date(&quot; + year + &quot;,&quot; + (month + 1) + &quot;))}else&quot;
+ &quot;{defaultCalendarChange(new Date(&quot; + year + &quot;,&quot; + (month + 1) +

&quot;))}\&quot;>\n></td>\n&quot;
+ &quot;<td&quot; + mouseStr + &quot; onclick=\&quot;if(typeof onCalendarChange == 'function'){&quot;
+ &quot;onCalendarChange(new Date(&quot; + (year + 1) + &quot;,&quot; + month + &quot;))}else&quot;
+ &quot;{defaultCalendarChange(new Date(&quot; + (year + 1) + &quot;,&quot; + month +

&quot;))}\&quot;>\n>></td>\n&quot;
+ &quot;</tr>\n&quot;
+ &quot;</table>\n&quot;
+ &quot;</td>\n</tr>\n&quot;

output += &quot;<tr>\n&quot;

//
//
//
//
//
// days of the week
for (var i = 0; i < 7; i++)
{
output += &quot; <td class=calDays>&quot; + shortDayNames + &quot;</td>\n&quot;
}
output += &quot; </tr>\n&quot;

// writes the table with the day numbers
// but first we have to find how big our table will be.
var bLen = (daysTotal + startDay);
var len = (bLen % 7) ? ( bLen + Math.abs((bLen % 7) - 7) ) : bLen ;


var today = new Date();
var coloredDay = (today.getFullYear() == year && today.getMonth() == month)? today.getDate() :

-100 ;

for (var i = (-7 + startDay); i < len; i++)
{
if (i < 0)
{
continue;
}

var cellDate = (i - startDay + 1);

if (i == 0)
{
output += &quot; <tr>\n&quot;;
}
else if (i % 7 == 0)
{
output += &quot; </tr>\n&quot;
+&quot; <tr>\n&quot;;
}


if ( (i >= startDay) && (cellDate <= daysTotal) && cellDate)
{
var dateStr = &quot;new Date(&quot; + this.getFullYear() + &quot;,&quot; + this.getMonth() + &quot;,&quot; + cellDate

+&quot;)&quot;;
output += &quot; <td class=calTdOff&quot;
+ &quot; onclick=\&quot;if(typeof onCalendarClick=='function')&quot;
+ &quot;{onCalendarClick(&quot; + dateStr + &quot;)}&quot;
+ &quot;else{defaultCalendarClick(&quot; + dateStr + &quot;)}\&quot;&quot;
+ &quot; onmouseover='this.className=\&quot;calTdOn\&quot;'&quot;
+ &quot; onmouseout='this.className=\&quot;calTdOff\&quot;' > &quot; + cellDate + &quot; </td>\n&quot;;
}
else
{
// puts the empty cells at the beginning and end of the month
output += &quot; <td class=calTdOff>&nbsp;</td>\n&quot;;
}

if (i == len)
{
output += &quot; </tr>\n&quot;
}
}
output += &quot; </table>\n</form>\n&quot;
return output;
}

Date.prototype.write = function()
{
document.write(this.getHtml())
}

Date.prototype.getHumanForm = function()
{
return this.getDate() + &quot;/&quot; + (this.getMonth()+1) + &quot;/&quot; + this.getFullYear()
}



//*** This chunk is the culprit
var _divs = new Array();
var _calDivId;
var _calField;
var _calFieldMs;
function getCalendarFor(field, id, fieldMs)
{
_calField = field;
_calFieldMs = fieldMs;
_calDivId = id;
var div = Div(_calDivId);
div.innerHTML = new Date().getHtml();
div.setAsBlock();
}



function reporter()
{
var p = [];

for (var prop in this)
{
if (typeof this[prop] != &quot;function&quot;)
{
p.push(prop + &quot;\t&quot; + this[prop] + &quot;\n&quot;);
}
}

return p;
}


function Div(id)
{
var obj = _dom ? document.getElementById(id) : document.all[id] ;

if

(!obj)
{
return false;
}

obj._id = _divs.length;

obj.time = 10; // how long

between moves
obj.distance = 2; // how far we move in one time unit

// visibility


obj.show = function(){obj.style.visibility = &quot;visible&quot;}
obj.hide =

function(){obj.style.visibility = &quot;hidden&quot;}
obj.isVisible = function(){return

(obj.style.visibility != &quot;hidden&quot;)}
obj.setZIndex = function(z){obj.style.zIndex = z}


obj.getZIndex = function(){return obj.style.zIndex}

// display
obj.setAsNone =

function(){obj.style.display = &quot;none&quot;}
obj.setAsBlock = function(){obj.style.display =

&quot;block&quot;}
obj.swapDisplay = function(){var flag = (obj.style.display != &quot;none&quot;);

obj.style.display = flag ? &quot;none&quot; : &quot;block&quot;; return (!flag);}

// size
obj.setHeight =
function(h){obj.style.height = h}
obj.setWidth = function(w){obj.style.width = w}


obj.getHeight = function(){return parseInt(obj.style.height)}
obj.getWidth = function(){return

parseInt(obj.style.width) }
obj.resizeTo = function(h, w){obj.setHeight(h ||

obj.getHeight());obj.setWidth(w || obj.getWidth())}

// position
obj.setLeft =

function(x){obj.style.left = x;return x}
obj.setTop = function(y){obj.style.top = y;return y}


obj.getLeft = function(){return parseInt(obj.style.left)}
obj.getTop = function(){return

parseInt(obj.style.top)}
obj.getPosition = function(){return [obj.getLeft(), obj.getTop()]}


obj.moveTo = function(x, y){return [obj.setLeft(x), obj.setTop(y)]}
obj.moveBy = function(x,

y)
{
return obj.moveTo( (x ? obj.getLeft() + x : obj.getLeft()),(y ? obj.getTop() + y :

obj.getTop()) )
}

obj.slideTo = function(left, top, lod, nextAction)
{
if

(!obj.sliding)
{
obj.slideFromPath(twoPointPath([obj.getLeft(), obj.getTop()], [left,

top], lod), nextAction)
}
}

obj.slideFromPath = function(path, nextAction)
{


obj.nextAction = nextAction;
obj.path = path.reverse();
obj._startSlideFromPath();
}



obj._startSlideFromPath = function()
{
if (!obj.sliding)
{
obj.sliding = true;


obj._slide();
}
}

obj._startSlide = function()
{
if (obj.sliding) return


obj.sliding = true;
repsTotal = Math.sqrt(Math.pow(obj.leftTravelDistance, 2) +

Math.pow(obj.topTravelDistance, 2)) / obj.distance
mX = obj.leftTravelDistance /

repsTotal;
mY = obj.topTravelDistance / repsTotal;

obj.path = [[obj.getLeft(),

obj.getTop()]];

for (var i = 0; i < repsTotal; i++)
{
var last =

obj.path.last();
obj.path.push([last[0] + mX, last[1] + mY])
}



obj.path.reverse();
obj._slide()
}

obj._slide = function()
{
if (obj.sliding)


{
if (obj.path.length)
{
var point = obj.path.pop();

obj.moveTo(point[0], point[1]);
setTimeout(&quot;_divs[&quot; + obj._id + &quot;]._slide()&quot;, obj.time)


return false;
}
else
{
obj.repsDone = 0;
obj.repsTotal

= 0;
obj.leftTravelDistance = 0;
obj.topTravelDistance = 0;
obj.sliding

= false;
eval(obj.nextAction)
obj.nextAction = &quot;&quot;
return true;
}


}
}

// clipping
obj.clip = function(trbl)
{
obj.style.clip = &quot;rect(&quot; + trbl +

&quot;)&quot;;
}

obj.getClip = function()
{

/rect\((\d{1,3})\D+(\d{1,3})\D+(\d{1,3})\D+(\d{1,3})\D+/i.test(obj.style.clip);
return

[RegExp.$1, RegExp.$2, RegExp.$3, RegExp.$4]
}

// special
obj.getOpacity = function()


{
/opacity=(\d{1,3})/i.test(obj.style.filter);
return (_ie) ? RegExp.$1 :

parseInt(obj.style.MozOpacity) ;
}

obj.setOpacity = function(o)
{
if (_moz)
{


obj.style.MozOpacity = o + &quot;%&quot;;
}
else if (obj.style.filter)
{


obj.style.filter = 'alpha(opacity=' + o +')'
}
}

obj.report = reporter;



_divs.push(obj)
return obj;
}

function fastBezierPoint(perc, start, flex1, flex2, end)
{


var oneMinusPerc = 1 - perc;
var bp1 = Math.pow(perc,3);
var bp2 = 3*Math.pow(perc,

2)*oneMinusPerc;
var bp3 = 3*perc*Math.pow(oneMinusPerc, 2);
var bp4 =

Math.pow(oneMinusPerc, 3);

return [ start[0]*bp1 + flex1[0]*bp2 + flex2[0]*bp3 + end[0]*bp4,


start[1]*bp1 + flex1[1]*bp2 + flex2[1]*bp3 + end[1]*bp4 ]
}

function

bezierPath(start, flex1, flex2, end, lod)
{
var iterations = lod ? lod : 100;
var iteration

= iterations;
var path = [];
while (iteration--)
{
path.push(fastBezierPoint(1 /

(iterations / iteration), start, flex1, flex2, end));
}
return path;
}

function

twoPointPath(start, end, lod)
{
var iterations = lod ? lod : 100;

var xMoveBy = (start[0]

- end[0]) / iterations;
var yMoveBy = (start[1] - end[1]) / iterations;

var path =

[[start[0], start[1]]];
var last;

while (iterations--)
{
last = path.last();


path.push([last[0] - xMoveBy, last[1] - yMoveBy])
}
return path;
}


function defaultCalendarClick(date)
{
if (_calField)
{
_calField.value = date.getHumanForm();
Div(_calDivId).setAsNone();
}
}


function defaultCalendarChange(date)
{
if(_calDivId)
{

Div(_calDivId).innerHTML = date.getHtml();
}
}

//*** end set of Calendar functions












<!-- We enclose javascript code so incompatible browsers do not display it as text.

hexColor = [&quot;0&quot;,&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;,&quot;6&quot;,&quot;7&quot;,&quot;8&quot;,&quot;9&quot;,&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;,&quot;f&quot;];

function mOver()
{
for (i = 0; i < 13; i++)
{
setTimeout('document.SubmitButtonForm.SubmitButton.style.background =

&quot;#'+hexColor[12-i]+'0'+hexColor[12-i]+'0c0&quot;;', i * 40);
}
}

function mOut()
{

for (i = 0; i < 13; i++)
{
setTimeout('document.SubmitButtonForm.SubmitButton.style.background =

&quot;#'+hexColor+'0'+hexColor+'0c0&quot;;', i * 40);
}
}
// End hiding of javascript. -->

</SCRIPT>

<!-- RedoWeek() dynamically updates the week field depending on what the date field is set to.

-->
<script language=VBSCRIPT>
sub RedoWeek(inDate)
if isDate(inDate.value) then
document.SubmitButtonForm.WeekField.value = DatePart(&quot;ww&quot;, inDate.value)
else
inDate.value = date()
end if
end sub
</script>



</HEAD>

<BODY class=&quot;SilverBackground&quot;>




<%
accessdb=&quot;UnsecuredTimesheet&quot;
cn=&quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot;
cn=cn & &quot;DBQ=&quot; & server.mappath(accessdb)
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

userName = replace(request.serverVariables(&quot;AUTH_USER&quot;),&quot;company\&quot;,&quot;&quot;)
userName = replace(userName,&quot;company\&quot;,&quot;&quot;)
userName = replace(userName,&quot;INTRANET\&quot;,&quot;&quot;)


' The string, sql, that will be read as the SQL statement.
sql = &quot;select top 15 * from ADMINRecordsTable where logonname = '&quot;&username&&quot;' ORDER BY TheDate

DESC&quot;



' Uncomment when debugging to display the value of sql
'response.write sql


rs.Open sql, cn
%>


<!-- Get the number of hours worked so far this week. -->
<%
accessdb=&quot;UnsecuredTimesheet&quot;
cn=&quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot;
cn=cn & &quot;DBQ=&quot; & server.mappath(accessdb)
Set rsHours = Server.CreateObject(&quot;ADODB.Recordset&quot;)

TheCurrentWeek = DatePart(&quot;ww&quot;, Now())

sql = &quot;select ADMINRecordsTable.Week, Sum(ADMINRecordsTable.Hours) AS [Weekly Hours],

Sum(ADMINRecordsTable.Hours)*24 AS [AsHours] from ADMINRecordsTable where

(ADMINRecordsTable.LogOnName = '&quot;&username&&quot;') And (ADMINRecordsTable.Week = &quot;&TheCurrentWeek&&quot;)

GROUP BY ADMINRecordsTable.Week ORDER BY ADMINRecordsTable.Week&quot;


' Uncomment when debugging to display the value of sql
'response.write sql


rsHours.Open sql, cn
%>



<!-- The top of the page, the heading etc. -->

<div id=&quot;TitleHeadingImage&quot;><img src=&quot;images/Colour_sml_6mm.jpg&quot; alt=&quot;Company logo&quot; />
<div id=&quot;TitleHeadingText&quot;>CompanyName <i class=&quot;LynxImpact&quot;>Project</i> Timesheet
<div id=&quot;TitleForName&quot;>For <%= username %></div></div></div>

<br /><br />
<div align=&quot;left&quot;>

<table BORDER=&quot;0&quot; BGCOLOR=&quot;#FFFFFF&quot; CELLSPACING=&quot;0&quot; align=&quot;left&quot; width=&quot;640&quot;>
<THEAD>


<!-- Display the amount of hours worked this week -->

<p class=&quot;StandOutTahoma&quot;>Total Hours Worked For This Week (decimal): <%= rsHours(&quot;AsHours&quot;)

%></p>


<tr>

<th valign=&quot;top&quot; align=&quot;left&quot;><font class=&quot;TableDataFont&quot;><br />Project Worked On</font></th>
<th valign=&quot;top&quot; align=&quot;left&quot;><font class=&quot;TableDataFont&quot;><br />Date</font></th>

<th valign=&quot;top&quot; align=&quot;left&quot;><font class=&quot;TableDataFont&quot;><br />Week</font></th>

<th valign=&quot;top&quot; align=&quot;left&quot;><font class=&quot;TableDataFont&quot;><br />Hours Worked</font></th>

</tr>
</THEAD>

<TBODY>

<%
'On Error Resume Next
rs.MoveFirst
do while Not rs.eof
%>


<tr VALIGN=&quot;TOP&quot;>


<td ALIGN=&quot;left&quot; valign=&quot;top&quot;>
<font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;>
<%= rs(&quot;Project&quot;) %>
</font></td>

<td ALIGN=&quot;left&quot; valign=&quot;top&quot;>
<font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;>
<%= rs(&quot;TheDate&quot;) %>
</font></td>


<td ALIGN=&quot;left&quot; valign=&quot;top&quot;>
<font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;>
<%= rs(&quot;Week&quot;) %>
</font></td>


<td ALIGN=&quot;left&quot; valign=&quot;top&quot;>
<font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;>
<%= rs(&quot;Hours&quot;) %>
</font></td>

</tr>

<%
rs.MoveNext
loop%>

<tr VALIGN=&quot;TOP&quot;>
<td ALIGN=&quot;left&quot; valign=&quot;top&quot;>
&nbsp;</td>

<td ALIGN=&quot;left&quot; valign=&quot;top&quot;>
&nbsp;</td>

<td ALIGN=&quot;left&quot; valign=&quot;top&quot;>
&nbsp;</td>

</tr>

</TBODY>


<font face = &quot;arial&quot; size=&quot;1&quot;>
<form method=&quot;post&quot; action=&quot;TypeInAndAddData.asp&quot; name=&quot;SubmitButtonForm&quot;>
<input type=&quot;hidden&quot; name=&quot;subject&quot; value=&quot;<%= title %>&quot;>

<input type=&quot;hidden&quot; name=&quot;u_fname&quot; size=&quot;20&quot; value=<% =username %> onFocus=&quot;this.blur()&quot; >
Project Field

<%
accessdb=&quot;UnsecuredTimesheet&quot;
cn=&quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot;
cn=cn & &quot;DBQ=&quot; & server.mappath(accessdb)
Set rsProject = Server.CreateObject(&quot;ADODB.Recordset&quot;)



sql = &quot;select LinkingEmpAndProjTable.ProjID from LinkingEmpAndProjTable where

((LinkingEmpAndProjTable.EmpID) = '&quot;&username&&quot;')&quot;


rsProject.open sql, cn
%>


<Select name = &quot;ProjectField&quot; >
<option selected>

<% While Not rsProject.EOF
%>

<option style=&quot;color:black&quot; value=&quot;<%=rsProject(&quot;ProjId&quot;)%>&quot;>


<%=rsProject.Fields(&quot;ProjId&quot;)%>


<%
rsProject.MoveNext
Wend
%>

<%
rsProject.Close

Set rsProject = Nothing

%>

</select>

<a href=&quot;TypeInAndAddData.asp&quot;>Refresh List</a>

<br />Commands&nbsp;&nbsp;
<input type=&quot;button&quot; value = &quot;&nbsp;&nbsp;Add Projects &nbsp;&nbsp;&quot; Action=&quot;<a href=&quot;&quot;

onClick=&quot;window.open('FavouriteProjects.asp','FavouriteProjects', 'height=150, width=420,

scrollbars=yes, resizable=yes '); return false;&quot;>



<input type=&quot;button&quot; value = &quot;Delete Projects&quot; Action=&quot;<a href=&quot;&quot;

onClick=&quot;window.open('DeleteFavouriteProjects.asp','DeleteFavouriteProjects', 'height=150,

width=420, scrollbars=yes, resizable=yes '); return false;&quot;>



<br /><br />


Date
<input type=&quot;text&quot; name=&quot;DateField&quot; size=&quot;11&quot; value=&quot;<%response.write Date()%>&quot;

onClick=&quot;RedoWeek(this)&quot; >

Week
<input type=&quot;text&quot; name=&quot;WeekField&quot; size=&quot;3&quot; value=&quot;<%response.write DatePart(&quot;ww&quot;, Now())%>&quot;>


Hours Worked
<input type=&quot;text&quot; name=&quot;HoursWorkedField&quot; size=&quot;8&quot;>


<input type=&quot;button&quot; value = &quot;&nbsp;Utilities&nbsp;&quot; Action=&quot;<a href=&quot;&quot;

onClick=&quot;window.open('Utilities.asp','Utilities', 'height=350, width=400, scrollbars=yes,

resizable=yes '); return false;&quot;>
<br />

<br />


<input type=&quot;submit&quot; onMouseOver='mOver()'' onMouseOut='mOut()' name=&quot;SubmitButton&quot;

value=&quot;&nbsp;&nbsp;Submit Details&nbsp;&nbsp;&quot;>
</form></font>


<input type=&quot;button&quot; name=&quot;DeleteRowsButton&quot; value=&quot;Delete Rows&quot; action=&quot;<a href=&quot;&quot;

onClick=&quot;window.open('DeleteRows.asp','DeleteRows', 'height=600, width=750, scrollbars=yes,

resizable=yes '); return false;&quot;>


<%
rs.Close
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

' Create new variables and initialise with data from the text boxes on the previous form.
LoginNameFieldText=request.form(&quot;u_fname&quot;)
ProjectFieldText=request.form(&quot;ProjectField&quot;)
DateFieldText=request.form(&quot;DateField&quot;)
WeekFieldText=request.form(&quot;WeekField&quot;)
HoursWorkedFieldText=request.form(&quot;HoursWorkedField&quot;)


' Put the SQL statement in to the variable sql. This string will be read and thus the command

given.


if len(ProjectFieldText) > 1 then

sql = &quot;INSERT INTO ADMINRecordsTable (LogOnName, Project, TheDate, Week, Hours) &quot;
sql = sql & &quot;values ('&quot; & LoginNameFieldText
sql = sql & &quot;','&quot; & ProjectFieldText
sql = sql & &quot;','&quot; & DateFieldText
sql = sql & &quot;','&quot; & WeekFieldText
sql = sql & &quot;','&quot; & HoursWorkedFieldText & &quot;')&quot;



' Uncomment when debugging to display the value of sql
'response.write sql

' Open in read and write mode
rs.Open sql, cn,3,3


else
response.write &quot;Fields are blank&quot;
end if
%>


<br /><br />
<FORM name=calendarForm>Click the text field to display the calendar for this
month.&nbsp; <INPUT style=&quot;WIDTH: 67px; HEIGHT: 19px&quot;
onfocus=&quot;getCalendarFor(this, &#13;&#13;&#10;'calendarDiv')&quot; size=1
name=calendarField>
<DIV id=calendarDiv style=&quot;DISPLAY: none&quot;></DIV></FORM>


<TFOOT>
</TFOOT>
</table>
</div>


</BODY>
</HTML>
 
Right the error is generated from this line

div.innerHTML = new Date().getHtml();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top