部分笔记,希望能帮到有困惑的人。一起学习。
<script type="text/javascript">
…………
function getpc_bh(){ //onchange
var select_zg_jb = document.form1.zg_jb.value;
var return_list_pcbh; //异步提交返回的数组
if(select_zg_jb!=""){
$.post("/zgsc/shqueryAction.do",
{"event":"queryByZg_jb",
"ZG_JB":select_zg_jb},
function(data){
return_list_pcbh = data; //后台文件流得到数据,要加个return null,
var list_pcbh = return_list_pcbh.substring(1,return_list_pcbh.length-1); //截掉数组的[]号
var pcbharray = list_pcbh.split(", "); //将返回的数组截取为分段数组
document.getElementById("pc_bh").options.length = 0; //先清空select框
$("#pc_bh").append("<option value=''></option>"); //设置默认值为空
for(var i=0;i<pcbharray.length;i++){ //循环将编号值拿出来,加到select里
var s = pcbharray[i].substring(pcbharray[i].indexOf("=")+1,pcbharray[i].length-1);
$("#pc_bh").append("<option value="+s+">"+s+"</option>");
}
});
}
//$.post(url:"shqueryAction.do",{"event":"queryByZg_jb","ZG_JB":select_zg_jb,async:false});
/*
下拉列表改变时触发的事件,将对应的批次编号载入批次编号下拉框
$.ajax({
type:"POST", //异步请求方式
data:"ZG_JB="+select_zg_jb, //传递的数据
url:"shqueryAction.do?event=queryByZg_jb", //请求路径 请求Action(继承DispatcherAction)中的login方法
success:show //异步请求成功后的回调函数
});
document.form1.action = "shqueryAction.do?event=queryByZg_jb&ZG_JB="+select_zg_jb;
document.form1.submit();
*/
/*
var select_pc_bh=document.form1.pc_bh; //得到批次编号控件对象
var zg_jb=document.form1.zg_jb.value; //得到资格级别控件对象
for(var i=1;i<=select_pc_bh.length;i++){
var pc_bh = select_pc_bh[i].value;
var bh = pc_bh.substring(pc_bh.length-1,pc_bh.length);
if(bh==zg_jb){
alert(zg_jb);
alert(bh);
}
}
*/
//document.getElementById("pc_bh").options.length = 0;
//document.getElementById("zg_jb").options.length = 0;
//document.getElementById("yh_mc").text = "";
}
$(document).ready(function() {
if("<bean:write property="ZG_JB" name="Shquery_form"/>"!=""){
$("#zg_jb").attr("value","<bean:write property="ZG_JB" name="Shquery_form"/>");
}
if("<bean:write property="YH_MC" name="Shquery_form"/>"!=""){
$("#yh_mc").attr("value","<bean:write property="YH_MC" name="Shquery_form"/>");
}
if("<bean:write property="PC_BH" name="Shquery_form"/>"!=""){
$("#pc_bh").attr("value","<bean:write property="PC_BH" name="Shquery_form"/>");
}
// $("#zg_jb").change(function(){
// $("#Project").load("shqueryAction.do?event=queryByZg_jb&ZG_JB="+$("#zg_jb").val());
//});
});
</script>
后台:
……
List listpcbh = service.queryPcByZgJb(model.getZG_JB());
model.setListPcbh(listpcbh);
response.getWriter().write(listpcbh.toString());//将取得的数据用文件输出流交给前台jquery
return null;
……
Comments | NOTHING