Calendar control

M

meg

I have a calendar control on my webpage, when I run it in preview it works, when i run it in IE I get the
error "Calendar1 is undefined". Can someone help me figure out how to correctly use this control? Thanks.

This is my code:

<script language="JScript" runat="server">
var oDate = new Date();
Session("sMonth") = oDate.getMonth() + 1 + "/";
Session("sDay") = oDate.getDate() + "/";
Session("sYear") = oDate.getYear();
</script>
<script language=JScript>
function ShowDate()
{
window.alert(Calendar1.Month + "/" + Calendar1.Day + "/" + Calendar1.Year + "\r\n" + Calendar2.Month + "/" +
Calendar2.Day + "/" + Calendar2.Year);
}
</script>
<table class=innertable>
<tr height=20>
<td>
Select Starting Date:
</td>
<td>
Select Ending Date:
</td>
</tr>
<tr valign=top height=50>
<td width=50>
<OBJECT id=Calendar1 style="LEFT: 0px; TOP: 0px"classid=clsid:8E27C92B-1264-101C-8A2F-040224009C02
VIEWASTEXT>
<PARAM NAME="_Version" VALUE="524288">
<PARAM NAME="_ExtentX" VALUE="6000">
<PARAM NAME="_ExtentY" VALUE="4000">
<PARAM NAME="_StockProps" VALUE="1">
<PARAM NAME="BackColor" VALUE="16777215">
<PARAM NAME="Year" VALUE="<%=Session("sYear")%>">
<PARAM NAME="Month" VALUE="<%=Session("sMonth")%>">
<PARAM NAME="Day" VALUE="<%=Session("sDay")%>">
<PARAM NAME="DayLength" VALUE="1">
<PARAM NAME="MonthLength" VALUE="1">
<PARAM NAME="DayFontColor" VALUE="0">
<PARAM NAME="FirstDay" VALUE="7">
<PARAM NAME="GridCellEffect" VALUE="0">
<PARAM NAME="GridFontColor" VALUE="10485760">
<PARAM NAME="GridLinesColor" VALUE="10485760">
<PARAM NAME="ShowDateSelectors" VALUE="-1">
<PARAM NAME="ShowDays" VALUE="-1">
<PARAM NAME="ShowHorizontalGrid" VALUE="-1">
<PARAM NAME="ShowTitle" VALUE="-1">
<PARAM NAME="ShowVerticalGrid" VALUE="0">
<PARAM NAME="TitleFontColor" VALUE="10485760">
<PARAM NAME="ValueIsNull" VALUE="0">
</OBJECT>
</td>
<td>
<OBJECT id=Calendar2 style="LEFT: 0px; TOP: 0px"classid=clsid:8E27C92B-1264-101C-8A2F-040224009C02
VIEWASTEXT>
<PARAM NAME="_Version" VALUE="524288">
<PARAM NAME="_ExtentX" VALUE="6000">
<PARAM NAME="_ExtentY" VALUE="4000">
<PARAM NAME="_StockProps" VALUE="1">
<PARAM NAME="BackColor" VALUE="16777215">
<PARAM NAME="Year" VALUE="<%=Session("sYear")%>">
<PARAM NAME="Month" VALUE="<%=Session("sMonth")%>">
<PARAM NAME="Day" VALUE="<%=Session("sDay")%>">
<PARAM NAME="DayLength" VALUE="1">
<PARAM NAME="MonthLength" VALUE="1">
<PARAM NAME="DayFontColor" VALUE="0">
<PARAM NAME="FirstDay" VALUE="7">
<PARAM NAME="GridCellEffect" VALUE="0">
<PARAM NAME="GridFontColor" VALUE="10485760">
<PARAM NAME="GridLinesColor" VALUE="10485760">
<PARAM NAME="ShowDateSelectors" VALUE="-1">
<PARAM NAME="ShowDays" VALUE="-1">
<PARAM NAME="ShowHorizontalGrid" VALUE="-1">
<PARAM NAME="ShowTitle" VALUE="-1">
<PARAM NAME="ShowVerticalGrid" VALUE="0">
<PARAM NAME="TitleFontColor" VALUE="10485760">
<PARAM NAME="ValueIsNull" VALUE="0">
</OBJECT>
</td>
</tr>
<tr valign=top>
<td>
<input id=startdate name=startdate type=text value="mm/dd/yyyy">
</td>
<td>
<input id=enddate name=enddate type=text value="mm/dd/yyyy">
</td>
</tr>
<tr>
<td><INPUT id="btnShow" type=button value=Button onclick="ShowDate();">
</td>
<td>
</td>
</tr>
</table>
 
J

Jens Peter Karlsen[FP MVP]

You can't address an ID directly. You must do it like this:
document.getelementbyid(Calender1).
Same goes for Calender2.

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
-----Original Message-----
From: meg [mailto:[email protected]]
Posted At: 21. april 2005 17:55
Posted To: microsoft.public.frontpage.programming
Conversation: Calendar control
Subject: Calendar control


I have a calendar control on my webpage, when I run it in
preview it works, when i run it in IE I get the error
"Calendar1 is undefined". Can someone help me figure out how
to correctly use this control? Thanks.

This is my code:

<script language="JScript" runat="server">
var oDate = new Date();
Session("sMonth") = oDate.getMonth() + 1 + "/";
Session("sDay") = oDate.getDate() + "/";
Session("sYear") = oDate.getYear();
</script>
<script language=JScript>
function ShowDate()
{
window.alert(Calendar1.Month + "/" + Calendar1.Day + "/" +
Calendar1.Year + "\r\n" + Calendar2.Month + "/" +
Calendar2.Day + "/" + Calendar2.Year); } </script> <table
class=innertable>
<tr height=20>
<td>
Select Starting Date:
</td>
<td>
Select Ending Date:
</td>
</tr>
<tr valign=top height=50>
<td width=50>
<OBJECT id=Calendar1 style="LEFT: 0px; TOP:
0px"classid=clsid:8E27C92B-1264-101C-8A2F-040224009C02
VIEWASTEXT>
<PARAM NAME="_Version" VALUE="524288">
<PARAM NAME="_ExtentX" VALUE="6000">
<PARAM NAME="_ExtentY" VALUE="4000">
<PARAM NAME="_StockProps" VALUE="1">
<PARAM NAME="BackColor" VALUE="16777215">
<PARAM NAME="Year" VALUE="<%=Session("sYear")%>">
<PARAM NAME="Month" VALUE="<%=Session("sMonth")%>">
<PARAM NAME="Day" VALUE="<%=Session("sDay")%>">
<PARAM NAME="DayLength" VALUE="1">
<PARAM NAME="MonthLength" VALUE="1">
<PARAM NAME="DayFontColor" VALUE="0">
<PARAM NAME="FirstDay" VALUE="7">
<PARAM NAME="GridCellEffect" VALUE="0">
<PARAM NAME="GridFontColor" VALUE="10485760">
<PARAM NAME="GridLinesColor" VALUE="10485760">
<PARAM NAME="ShowDateSelectors" VALUE="-1">
<PARAM NAME="ShowDays" VALUE="-1">
<PARAM NAME="ShowHorizontalGrid" VALUE="-1">
<PARAM NAME="ShowTitle" VALUE="-1">
<PARAM NAME="ShowVerticalGrid" VALUE="0">
<PARAM NAME="TitleFontColor" VALUE="10485760">
<PARAM NAME="ValueIsNull" VALUE="0">
</OBJECT>
</td>
<td>
<OBJECT id=Calendar2 style="LEFT: 0px; TOP:
0px"classid=clsid:8E27C92B-1264-101C-8A2F-040224009C02
VIEWASTEXT>
<PARAM NAME="_Version" VALUE="524288">
<PARAM NAME="_ExtentX" VALUE="6000">
<PARAM NAME="_ExtentY" VALUE="4000">
<PARAM NAME="_StockProps" VALUE="1">
<PARAM NAME="BackColor" VALUE="16777215">
<PARAM NAME="Year" VALUE="<%=Session("sYear")%>">
<PARAM NAME="Month" VALUE="<%=Session("sMonth")%>">
<PARAM NAME="Day" VALUE="<%=Session("sDay")%>">
<PARAM NAME="DayLength" VALUE="1">
<PARAM NAME="MonthLength" VALUE="1">
<PARAM NAME="DayFontColor" VALUE="0">
<PARAM NAME="FirstDay" VALUE="7">
<PARAM NAME="GridCellEffect" VALUE="0">
<PARAM NAME="GridFontColor" VALUE="10485760">
<PARAM NAME="GridLinesColor" VALUE="10485760">
<PARAM NAME="ShowDateSelectors" VALUE="-1">
<PARAM NAME="ShowDays" VALUE="-1">
<PARAM NAME="ShowHorizontalGrid" VALUE="-1">
<PARAM NAME="ShowTitle" VALUE="-1">
<PARAM NAME="ShowVerticalGrid" VALUE="0">
<PARAM NAME="TitleFontColor" VALUE="10485760">
<PARAM NAME="ValueIsNull" VALUE="0">
</OBJECT>
</td>
</tr>
<tr valign=top>
<td>
<input id=startdate name=startdate type=text value="mm/dd/yyyy">
</td>
<td>
<input id=enddate name=enddate type=text value="mm/dd/yyyy">
</td>
</tr>
<tr>
<td><INPUT id="btnShow" type=button value=Button
onclick="ShowDate();">
</td>
<td>
</td>
</tr>
</table>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top