在使用 jQuery UI 自动完成为隐藏输入设置值之后
$( "#PName" ).autocomplete({
search: function(event, ui) {
$("#PLoading").show();
},
source: "Script_URL",
minLength: 2,
select: function( event, ui ) {
$("#PLoading").hide();
$("#PName").val(ui.item.value);
$("#PID").val(ui.item.id);
}
});
<input type="hidden" id="PID" name="PID" value="0" />
对于使用自动完成从隐藏输入向其他 url 发送新值,发送 0 值
0 值是隐藏输入默认值,(为了测试,我将默认值更改为 90,但再次发送默认值(90))
$("#CName").autocomplete({
search: function(event, ui) {
$("#CLoading").show();
alert ($("#PID").val()); // it's worked, and alert new value , from hidden input
},
source: "Script_URL/"+$("#PID").val(), /// but it's not worked , does not send new value from hidden input
minLength: 2,
select: function( event, ui ) {
$("#CLoading").hide();
$( "#CName" ).val(ui.item.value);
$( "#CID" ).val(ui.item.id);
}
});