changing select options based on text value in another field 
Author Message
 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>



Sun, 10 Aug 2003 05:28:29 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. changing select options based on previously selected options

2. Changing the option values in Select Control

3. change form action based on value in text box

4. Making hidden fields visible based on a form field value

5. modifying form options in one field based on another

6. <option Selected> based on variable

7. select form field based on tab index

8. Add fields to a form by selecting the option to do so

9. Openfile based on value in a field

10. ?Selecting/Indexing Options elements by Name value

11. ?Selecting/Indexing Options elements by Name value

12. capture selected option value without form submission

 

 
Powered by phpBB® Forum Software