This is a newbie question. I've been using jQuery for a day or so.
I simply want to capture each change in a drop down menu.
Here's my drop down menu and reference:
<script src="Scripts/insertRootCauseElements.js" type="text/javascript"></script>
<asp:DropDownList ID="DropDownListRootCause" runat="server" > </asp:DropDownList>
Here's my handler:
$(document).ready(function () {
// var selectedValue = $('#DropDownListRootCause').selectedValue;
//var selectedIndex = $('#DropDownListRootCause').selectedIndex;
alert("HERE");
$('#DropDownListRootCause').change(function () {
alert("Changed " + $('#DropDownListRootCause').selectedIndex);
})
.change();
// if ($('#DropDownListRootCause').change) {
// alert("dd change " + selectedIndex);
// }
})
I've tried a lot of variations but nothing is working for me. On debugging, it seems my jQuery doesn't know what "DropDownListRootCause" is.
I set AutoPostBack=true in my dd control which finds my jQuery but
$('#DropDownListRootCause').change(function () {
alert("Changed " + $('#DropDownListRootCause').selectedIndex);
})
Still evals to false.
I added DropDownListRootCause to 'Watch' when debugging which reveals 'DropDownListRootCause' is undefined'. I've tried double and single quotes but no luck.
It must be something simple but I can't see it. Can someone help?