1
IM,的jquery-UI-自动完成使用以下代码填充其它输入
JS
<script>
$(function() {
function log(message) {
$("<div>").text(message).prependTo("#log");
$("#log").scrollTop(0);
}
$("#input").autocomplete({
source: "source.php",
minLength: 2,
select: function(event, ui) {
log(ui.item ?
"SelectedName: " + ui.item.value + " -SelectedID: " + ui.item.ID:
"Nothing selected, input was " + this.value);
}
});
PHP/HTML
<tr>
<td colspan="2">Input</td>
<td colspan="2" >
<input class="glowing-border" id="input">
</td>
</tr>
<div class="ui-widget" style="margin-top:2em; font-family:Arial">
Result:
<div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
</div>
这工作完全。但我在这里卡住了,因为我想把结果分成两部分。现在,在div获取显示:
“selectedName:theName - SelectedID:12345”
但是,我需要填写其他输入字段这两个值,有北京时间输入字段<input id="selectedText">
和一个<input id="selectedID">
我该怎么做?
2.)当我在“输入”中键入somthing时,我只能从db中获得匹配的文本。是否有可能在列表框中显示ID?