autoThink

JS
<link href="<%=request.getContextPath()%>/css/jquery.autocomplete.css" rel="stylesheet" type="text/css">
<script src="<%=request.getContextPath()%>/js/poapply/jquery.autocomplete.js" type="text/javascript" charset="utf-8" ></script>
//解析json数据
function parseFn(data) {
alert(data.jsonData);
var rows = [];
if(data==null)
return rows;
for(var i=0; i<data.length; i++){
rows[rows.length] = {
data:data[i],
result:data[i].PO_NO
};
}
return rows;
}
//自动联想
function getAutoThinkOpts(){
var options={
minChars: 1,
max: 10,
autoFill: false,
mustMatch: false,
matchSubset: false,
matchContains: true,
scrollHeight: 220,
width:200,
matchCase:true,
selectFirst: false,
scroll:false,
dataType: 'json',
parse: parseFn,
formatItem: function(row, i, total) {
return " "+row.PO_NO+" ";
},
formatMatch: function(row, i, total) {
return row.PO_NO;
},
formatResult: function(row) {
return row.PO_NO;
}
};
return options;
}

function initAutoThink(){
var opts = getAutoThinkOpts();
var contractNO = $("#contractNo").val();//$("[name=contractNo]").val();
alert(contractNO)
//$("[name=orderNo]").unautocomplete();
$("#orderNo").unautocomplete();
if(contractNO != ""){
alert(contractNO);
$("#orderNo").autocomplete("/supportmng/pages/usermanage/user/listUserInfo.do?actionFlag=getContractAndSWInfo&contract_no="+contractNO,opts);
}
}

$(document).ready(function(){
initAutoThink();
$("#contractNo").bind("change",initAutoThink);


})


JSP
contractNo:<input type="text" value="" size="20" name="web_doc_id2" id="contractNo">
orderNo:<input type="text" value="" size="20" name="web_doc_id" id="orderNo" autocomplete="off" class="ac_input">

ACTION
public ActionForward getContractAndSWInfo(ActionMapping aMapping,
ActionForm aForm, HttpServletRequest aRequest,
HttpServletResponse aResponse) throws Exception
{
aResponse.setContentType("text/html;charset=UTF-8");
aRequest.setCharacterEncoding("UTF-8");
aResponse.setHeader("Cache-Control", "no-cache");
//合同号
String contractNo = aRequest.getParameter("contract_no");
if (null != contractNo && !"".equals(contractNo))
{
contractNo = contractNo.trim();
}
//订单号
String po_no = aRequest.getParameter("q");
HttpSession session = aRequest.getSession(false);
String nls = (String) session.getAttribute(SupportConstants.CFG_NLS);
JSONObject param = new JSONObject();
param.put("CONTRACT_NO", contractNo);
param.put("PO_NO", po_no);
param.put("LIMIT",10);
param.put("NLS_LANG", nls);
IPoApplyWs poApplyWs = new IPoApplyWsProxy();
String autoDataStr =poApplyWs.getPoNoInfo(param.toString());
JSONArray jsonData = new JSONArray(autoDataStr);
PrintWriter out = aResponse.getWriter();
out.write(jsonData.toString());
// out.flush();
if(null != out){
out.close();
}
return null;

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值