I am trying to get the value of a dropdown when changing (and then change the values in the second drop down).
EDIT: Thanks for all the answers, I updated to add (), but the code returns nothing, not null or undefined just an empty warning window
However, when I warn about this, the value of attr (value) is undefined.
Any ideas on what I am missing?
Here is my code:
<script type="text/javascript">
$(document).ready(function() {
var roomID = "0"
$('.dropone').load('ajaxdropdown.aspx');
$('.droptwo').load('ajaxdropdown.aspx?drpType=room&roomid=' + roomID);
$('.dropone').change(function() {
var ts = new Date().getTime();
alert($(this).val)
$(".droptwo").empty();
$(".droptwo").load("ajaxdropdown.aspx?drpType=room&roomid=" + $(this).attr("value") + "&ts=" + ts);
});
});
</script>
TMB87 source
share