multichild
Programmer
I have a form that contains a variety of functions for a tutorial. I have a problem with one of the functions, in that the date doesnt display straight away without selecting a month first.
Accend Web Solutions
Code:
<script language="javascript">
function updateDay() {
// Clear existing values from the Day List
var theDayList = window.document.form1.eventDate;
var optionCounter;
for (optionCounter = theDayList.length - 1; optionCounter >= 0 ; optionCounter --)
{
theDayList.options[optionCounter] = null;
}
// Add values from the appropriate hidden field
var vYear = window.document.form1.eventYear.value;
var vMonth = window.document.form1.eventMonth.value;
var x = 0;
for (x=1; x<32; x++)
{
var vDate = vMonth + "/" + x + "/" + vYear;
var chkDate = new Date(vDate);
if (chkDate.getMonth()+1 == vMonth)
{
var option = new Option(x,x);
theDayList.options[x-1] = option;
}
}
}
</script>
<script>
function monthName() {
MonthName(request.form("eventMonth"))
}
</script>
<tr>
<td><strong>Day:</td>
</tr>
<tr>
<td>
<select name="eventDay">
<option>Monday</option>
<option>Tuesday</option>
<option>Wednesday</option>
<option>Thursday</option>
<option>Friday</option>
<option>Saturday</option>
<option>Sunday</option>
</select>
</td>
</tr>
<tr>
<tr>
<td>Month:</td>
</tr>
<tr>
<td>
<select name="eventMonth" onchange="updateDay()">
<%
theMonth = month(now())
for x = 1 to 12
if theMonth = x then
response.write("<option selected value='" & x & "'>" & monthname(x) & "</option>")
else
response.write("<option value='" & x & "'>" & monthname(x) & "</option>")
end if
next
%>
</select>
</td>
</tr>
<tr>
<td>Date:</td>
</tr>
<tr>
<td>
<select name="eventDate"></select>
</td>
</tr>
<tr>
<td><strong>Year:</td>
</tr>
<tr>
<td>
<Select name="eventYear" onchange="updateDay()">
<%
for x = 0 to 9
theYear = Year(now()) + x
if theYear = year(now()) then
response.write("<option selected value='" & theYear & "'>" & theYear & "</option>")
else
response.write("<option value='" & theYear & "'>" & theYear & "</option>")
end if
Next
%>
</select>
</td>
</tr>
Accend Web Solutions