Select list value undefined in $(document).ready
Posted
by C. Ross
on Stack Overflow
See other posts from Stack Overflow
or by C. Ross
Published on 2010-03-21T23:58:25Z
Indexed on
2010/03/22
0:01 UTC
Read the original article
Hit count: 251
I have the following code, which I want to load values on a selection change, and also do the selection load initially (since FF 'saves' the last value of the drop down under certain circumstances). The select part of the function works correctly, but for some reason when calling load2
directly the value of $('#select1').value
is undefined
, even though when I check the DOM in Firebug right after load select1.value
has a value. How can I run the load2
function when select1.value
is ready?
$(document).ready(function() {
//Setup change hook
$('#select1').change(function(event) {
//Remove the old options right away
$('#select2').find('option').remove();
//Load the new options
load2(this.value);
});
//Do load for current value
load2($('#select1').value);
});
© Stack Overflow or respective owner