PDA

View Full Version : Jason's Date Input Calendar - how to start the calendar at a known date taken from DB



marulya
11-03-2005, 04:25 PM
I'm writing an asp with connection to MS SQL Server 2000 and I would like to use this calendar ( http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm ) to input and update dates. I have some functions to initialize the date field which is to be submited and this is how I do it:



<script>
function getDatePicker() {
return this.form_name.orderdate.value;
}

function initDateOfCutOff() {
this.form_name.DateOfCutOff.value = getDatePicker();
}
</script>

...

<input type="submit" class="btn" name="update" value="Save" onClick="initDateOfCutOff()">


Here is the problem, this code works fine and initializes the calendar:



<input type="hidden" name="oldDateOfCutOff" value="<%= details.Fields.Item("DateOfCutOff") %>">
<script>DateInput('orderdate', false, 'MM/DD/YYYY', '11/24/2005')</script>
<input type="hidden" name="DateOfCutOff">
<input type="button" onClick="alert(this.form.oldDateOfCutOff.value.toString())" value="Show old date value">


But the effect of this code is no calendar shown, although details.Fields.Item("DateOfCutOff") equals 11/24/2005:



<input type="hidden" name="oldDateOfCutOff" value="<%= details.Fields.Item("DateOfCutOff") %>">
<script>DateInput('orderdate', false, 'MM/DD/YYYY', this.form.oldDateOfCutOff.value.toString())</script>
<input type="hidden" name="DateOfCutOff">
<input type="button" onClick="alert(this.form.oldDateOfCutOff.value.toString())" value="Show old date value">


The effect of this code is also no calendar shown:



<input type="hidden" name="oldDateOfCutOff" value="11/24/2005">
<script>DateInput('orderdate', false, 'MM/DD/YYYY', this.form.oldDateOfCutOff.value.toString())</script>
<input type="hidden" name="DateOfCutOff">
<input type="button" onClick="alert(this.form.oldDateOfCutOff.value.toString())" value="Show old date value">


I'll be very thankful if you help me. Thank you in advance!

marulya
11-04-2005, 05:08 PM
I just want to post the solution that worked for me:


<%
if isnull(details("DateOfCutOff")) then
%>
<script>DateInput('DateOfCutOff', true, 'MM/DD/YYYY')</script>
<%
else
%>
<script>DateInput('DateOfCutOff', true, 'MM/DD/YYYY', <% Response.Write("'" & details("DateOfCutOff") & "'") %>)</script>
<%
end if
%>