I have some problems sending an id though jquery.
I have a form select with some values, i want to “grap” the id when change option selection.
Output error: [object Object] !! :/
<select name="case_name" id="case_id">
<option value="10009" >Case 1</option>
<option value="10010" >Case 2</option>
<option value="10011" >Case 3</option>
</select>
var PARAMS = { "case_id": 10009 };
$("#case_id").change(function() {
var CASE_ID = $(this).val();
var PARAMS = { "case_id": CASE_ID };
alert(CASE_ID);
});
CASE_IDis defined inside an anonymous function and is only valid inside this function. And inside the callback you can simply refer to the select box asthis.Outside the anonymous function, it does not exist.
Either modify the
changecallback to include the PARAMS object.Or fetch the value again
Or maybe define a function that you pass the new selected value to: