Justin Self
Justin Self

Reputation: 6265

IE7 not returning value of drop down

I have a small javascript control that allows users to select a date and time.

Part of the control uses another date selector. This date selector works as expected and puts the selected value in a field. The users then select the hour, the minutes (in 15 min increments) and am/pm from drop downs.

The data comes to look like this:

followUpDate = 10/24/2012
hour = 06
minute = 30
ampm = AM

However, IE7 will not return the values of the dropdown.

I'm using

var hour = e.options[e.selectedIndex].value;

and the hour (and subsequent variables) are still undefined in IE7. However, the values are correct in IE8+ and the other major browsers.

Upvotes: 2

Views: 255

Answers (1)

Justin Self
Justin Self

Reputation: 6265

My problem was I was using:

var hour = e.options[e.selectedIndex].value;

instead of:

 var hour = e.options[e.selectedIndex].text;

So IE7 wouldn't get the value of the dropdowns kept the values at undefined. However, IE8+ and the other browsers accepted .value and worked as expected.

Upvotes: 2

Related Questions