I am trying to automatically select a parameter in select by jquery after selecting the value of the parameter I want to select. However, it does not work in Chrome. It works in firefox and IE 9. Why so? Function filling is a value that fills the values. (res function, only resets the values filled in by filling in the function, and does not matter for this question)
function fill(thisValue) {
$('#inputString').val(thisValue);
$.post("get.php?op=category", {queryString: ""+thisValue+""}, function(data){
if(data.length >0) {
$("#mymenu option[value='"+data+"']").attr('selected', 'selected');
$('#mymenu').attr("disabled","disabled");
}
});
$.post("get.php?op=name", {queryString: ""+thisValue+""}, function(data){
if(data.length >0) {
$('#nameString').val(data);
$('#nameString').attr("disabled","disabled");
}
});
$.post("get.php?op=author", {queryString: ""+thisValue+""}, function(data){
if(data.length >0) {
$('#authorString').val(data);
$('#authorString').attr("disabled","disabled");
}
});
$.post("get.php?op=publisher", {queryString: ""+thisValue+""}, function(data){
if(data.length >0) {
$('#publisherString').val(data);
$('#publisherString').attr("disabled","disabled");
}
});
setTimeout("$('#suggestions').hide();", 200);
}
function res(inputString) {
$('#publisherString').attr("disabled", false);
$('#publisherString').val('');
$('#nameString').attr("disabled",false);
$('#nameString').val('');
$('#authorString').attr("disabled",false);
$('#authorString').val('');
$('#mymenu').attr("disabled",false);
$('#mymenu option').attr('selected', false);
}
source
share