I'm trying to check if the '#text' (id for a textarea) is empty when I change '#my_selection' (id for a drop-down select) option. And if NOT EMPTY (ie, there's some text in the textarea), I would like the confirmation to pop up, else don't want to change the
'#my_selection'.
Many thanks in advance.
var selected=$('#my_selection').val();
$('#my_selection').change(function(){
if($("#text").val() != ""){
var check=confirm("change?");
if(check){
selected=$(this).val();
$('#my_selection').val(selected);
}else{
$(this).val(selected);
}
}
});