Enter the user name to send the request to the background, return the user's CustID, save to the form, and then submit. Search by CustID.
$ ("#custNameButton"). Click (function () {
var custname=$ ("#custName");
var value = Custname.val ();
if (value.length==0) return;
var selectbox=$ ("<div></div>");
Selectbox.addclass ("Select4_box");
$.ajax ({
"ContentType": "Application/x-www-form-urlencoded;charset=utf-8",
"Type": "Post",
"DataType": "JSON",
"Data": {
Name:value
},
URL: "${ctx}/xxxx/xxxxx/xxxdata",
Success:function (data) {
if (Custname.parent (). Find (". Select4_box"). length>0) Custname.parent (). Find (". Select4_box"). Remove ();
var ul=$ ("<ul></ul>");
$.each (data.data| | [],function (Index,item) {
var li=$ ("<li></li>");
Li.attr ("Data-id", item.id);
Li.text (Item.name);
Li.click (function () {
Custname.val ($ (this). text ());
$ ("#custId"). Val ($ (this). attr ("Data-id"));
$ (this). Closest (". Select4_box"). Remove ();
});
Ul.append (LI);
});
Selectbox.append (UL);
Custname.parent (). append (Selectbox);
}
});
});
=========================================
<form:hidden path= "CustId"/>
<label> User Nickname:</label>
<div class= "Input-append" >
<form:input path= "CustName" htmlescape= "false" Maxlength= "$" class= "Input-small" id= "CustName"/>
<a id= "Custnamebutton" href= "javascript:" class= "btn" style= "" > <i class= "Icon-search" ></i > </a>
</div>
Click the text box search, which appears in the drop-down list