2 つのテキスト フィールドがあります (オートコンプリート機能付き)。
<label for="name">Customer:</label>
<input type="text" name="customer" id="customer" value="" />
<input type="hidden" id="customer-id" />
<p id="customer-description"></p>
<label for="name">Store:</label>
<input type="text" name="store" id="store" value="" disabled="true" />
<input type="hidden" id="store-id" />
<p id="store-description"></p>
ご覧のとおり、最初は 2 番目のテキストフィールドを無効にしました。私が望むのは、ユーザーが顧客のテキストボックスからアイテムを選択したときに、ストアのテキストボックスが有効になることです。これは私が試したものですが、ストアフィールドを有効にしません:
$(function() {
$('#customer').autocomplete({
source: "./SearchCustomer.php?term="+document.getElementById("customer").value,
minLength: 0,
focus: function( event, ui ) {
$( "#customer" ).val( ui.item.label );
return false;
},
select: function (event, ui) {
$( "#customer" ).val( ui.item.label );
$( "#customer-id" ).val( ui.item.value );
return false;
}
})
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" ).append( "<a>" + item.label + "</a>" ).appendTo( ul );
};
$("#store").removeAttr("disabled").focus();
});
あなたの助けに感謝します。