tags:

views:

172

answers:

2
+3  A: 
$("#state").change(function(){
    //on-change code goes in here.
    //variable "this" references the state dropdown element
});
Graza
how do i get the id of a parent (country) dropdown element?
Abu Hamzah
"country" is not a "parent" in the HTML above, it's simply another element. The above code, but replacing `#state` with `#country` would get what you want. Or am I misunderstanding? Do you want the "previous" element instead?
Graza
+1  A: 

@Abu: $(this).parent("select").attr("id");

derek
under which <select> is the element that you are currently in? IF you're in an element under the state select, then you would simply do: $("#country").val();
derek
let me try and get back to you.
Abu Hamzah
here is the updatei get the value by doing $("#country").val();okay... when the page load very first time it populates all my country but when i change to other country it does not fire for the first time but it does fire (onchange event) when i change the country second time... why is it?
Abu Hamzah
i have append the latest code, please have a look at it. - thanks.
Abu Hamzah
by populating the dropdown using ajax, it's selected value is not getting saved in the viewstate. Perhaps you could pass the selected value in the querystring on postback so you can re-select the value on page load.
derek