问题描述
我正在使用jquery自动完成功能来搜索userName,我想显示user-id的值
脚本:
<script type="text/javascript">
var CSRF_TOKEN = $('Meta[name="csrf-token"]').attr('content');
$(document).ready(function(){
$( "#userName_search" ).autocomplete({
minLength: 3,delay: 500,source: function( request,response ) {
$.ajax({
url:"{{ route('backend.users.fetch') }}",type: 'post',dataType: "json",data: {
_token: CSRF_TOKEN,search: request.term
},success: function( data ) {
response( data );
}
});
},select: function (event,ui) {
$('#userName_search').val(ui.item.label); // display the selected text
$('#id').val(ui.item.value); // save selected id to input
return false;
}
});
});
</script>
输入:
<div class="form-group">
<input type="text" name="userName" id="userName_search" class="form-control input-lg" required>
<input type="text" id="id" class="form-control input-lg" readonly >
</div>
现在在两个单独的输入中显示
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)