Javascript: Get Value of DropDown

I have 2 drop-down lists on my page.  

ddlStartTime
ddlEndTime

Both dropdowns hold the same exact time values, from 8:00 AM to 5:00 PM in half hour increments.

 When a user selects a time in the ddlStartTime DropDownList I want to onChange or onSelect (I'm not sure which) I want the ddlEndTime to change to the time the user select in the ddlStartTime.

So if I choose 10:30 AM, the ddlEndTime value should automatically select 10:30 AM.

How is this done?
cdemott33Asked:
Who is Participating?
 
leakim971PluritechnicianCommented:
<select id="ddlStartTime" onchange="if(document.getElementById('ddlEndTime').selectedIndex<this.selectedIndex) document.getElementById('ddlEndTime').selectedIndex=this.selectedIndex">

and

<select id="ddlStartTime" onchange="if(document.getElementById('ddlStartTime').selectedIndex<this.selectedIndex) document.getElementById('ddlStartTime').selectedIndex=this.selectedIndex">
0
 
cdemott33Author Commented:
Hi leakim971 - Unfortunately that did work.  I'm getting an error stating "Object not found".  This is an ASPX page, so I don't know if it needs to be coded differently.  I added the script via the code behind as follows:
ddlStartTime.Attributes.Add("onChange", "if(document.getElementById('ddlEndTime').selectedIndex<this.selectedIndex) document.getElementById('ddlEndTime').selectedIndex=this.selectedIndex")

Open in new window

0
 
cdemott33Author Commented:
Sorry... typo... I ment to say that your code did not work.
0
 
leakim971PluritechnicianCommented:
Dis you notice << id >>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.