
changing select options based on text value in another field
I am trying to change the options available in a form select based on the
text changes in another field.
The first script and input is a little calendar that populates the text
field. The <% =Date %> is an ASP
VBScript that fills in 2/20/01 (or whatever
the current date is).
It works properly when I change the date the first time, but not when I
change the value back to the current date. And if the calendar changes the
text field, it doesn't work at all. I'd appreciate any help
<html>
<head>
<SCRIPT language=javascript type=text/javascript event=onclick()
for=document>
popCal.style.visibility = "hidden";
</SCRIPT>
<script language=javascript>
function changeTimesAvailable(form,currentField) {
if (currentField == "<%= Date %>") {
document.schedule.StartTime.options[0].value =
document.schedule.StartTime.options[0].text = 'A';
document.schedule.StartTime.options[1].value =
document.schedule.StartTime.options[1].text = 'B';
document.schedule.StartTime.options[2].value =
document.schedule.StartTime.options[2].text = 'C';
}
else {
document.schedule.StartTime.options[0].value =
document.schedule.StartTime.options[0].text = 'D';
document.schedule.StartTime.options[1].value =
document.schedule.StartTime.options[1].text = 'E';
document.schedule.StartTime.options[2].value =
document.schedule.StartTime.options[2].text = 'F';
}
Quote:
}
</script>
</head>
<body>
<form name="schedule" method="POST" target="main"
action="Add_event2.asp">
<input type=text name="StartDate" size="10" value="<%= Date %>"
onchange="changeTimesAvailable(this.form,this.name);">
<br>
<br>
<input type=image src=images/cal.gif
onClick="popFrame.popupCalendar(StartDate,StartDate,popCal);return false">
<br>
<br>
<select size="1" name="StartTime">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<br>
</form>
</body>
</html>