日期:2014-05-16 浏览次数:20490 次
1:在界面把数据封装成JSON字符窜: 格式如下:
?
???? {"a":"1","b":"2","c":[{"d":"3","e":"4"},{"d":"3","e":"4"}]}
?
???? 界面js如下:
?
????
//一个字符串数据
function getJsons(){
var zlf = checkCongfu("zhonglei");
if(!zlf){
return "";
}
var sfxm = document.getElementById("sfxm").value;
if(sfxm==2){
var fzxamt = document.getElementById("fzxamt").value;
var zxel = document.getElementsByName("xnamt");
var ed = document.getElementById("namt").value;
var fpsum = 0;
for(var i=0;i<zxel.length;i++){
if(zxel[i].value!=""){
fpsum = fpsum + parseFloat(getNum(zxel[i].value));
}
}
fpsum = fpsum+parseFloat(getNum(fzxamt));
if(parseFloat(getNum(ed))<fpsum){
alert("调整额度小于分配额度");
return "";
}
}
var mx = document.getElementsByName("dbxz");
var namt = document.getElementById("namt");
var allused = document.getElementById("usedamt");
var danbao = document.getElementsByName("danbao");
var zhonglei = document.getElementsByName("zhonglei");
var odi = document.getElementById("oid");
var appid = document.getElementById("appid");
if(namt.value!=""){
var r = new StringBuffer('{ \"namt\":\"');
var tzsm = document.getElementById("othersVal");
r.append(parseFloat(getNum((namt.value)))*10000);
r.append('\",\"oid\":\"');
r.append(odi.value);
r.append('\",\"tzsm\":\"');
r.append((tzsm.value));
r.append('\",\"cor\":\"');
r.append('<%=cror%>');
r.append('\",\"appid\":\"');
r.append(appid.value);
r.append('\",\"allused\":\"');
r.append(0);
r.append("\"");
if(sfxm==2){
r.append(',\"mx\":');
var tempr =new StringBuffer("[");
var zhonglei = document.getElementsByName("zhonglei");
//var jyed = parseFloat(getNum(document.getElementsByName("xnamt")))*10000;
var jyed = document.getElementsByName("xnamt")
var danbao = document.getElementsByName("danbao");
var danbaosm = document.getElementsByName("xnwartcmt");
var f = false;
tempr.append('{\"zhonglei\":\"');
tempr.append(100);
tempr.append('\", \"xnamt\":\"');
tempr.append(parseFloat(getNum(document.getElementById("fzxamt").value))*10000);
tempr.append('\", \"usedamt\":\"');
tempr.append(parseFloat(getNum(document.getElementById("fzxamt").a))*10000);
tempr.append('\",\"danbao\":\"');
tempr.append(danbao[0].value);
tempr.append('\",\"danbaosm\":\"');
tempr.append(document.getElementById("fzxnwartcmt").value);
tempr.append('\"},');
if(danbao[0].value==""){
alert("请填写担保方式!");
danbao[0].focus;
return "";
}
for(var i=0 ; i<mx.length;i++){
//if(mx[i].checked==true || jyed[i].value!=""){
//alert(jyed[i].value);
if(jyed[i].value!=""){
if(jyed[i].value==""){
alert("请填写额度!");
jyed[i].focus;
return "";
}
if(danbao[i+1].value==""){
alert("请填写担保方式!");
danbao[i+1].focus;
return "";
}
if(zhonglei[i].value==""){
alert("请填写授信种类!");
zhonglei[i].focus;
return "";
}
tempr.append('{\"zhonglei\":\"');
tempr.append(zhonglei[i].value);
tempr.append('\", \"xnamt\":\"');
tempr.append(parseFloat(getNum(jyed[i].value))*10000);
tempr.append('\", \"usedamt\":\"');
//if(jyed[i].a!=null && jyed[i].a!=""){
//tempr.append(parseFloat(getNum(jyed[i].a))*10000);
//}else{
tempr.append(0);
//}
tempr.append('\",\"danbao\":\"');
tempr.append(danbao[i+1].value);
tempr.append('\",\"danbaosm\":\"');
tempr.append(danbaosm[i].value);
tempr.append('\"},');
f = true;
}else{
//alert("请填写额度!");
//jyed[i].focus;
//return "";
}
}
tempr =tempr.substringBetween(0,tempr.getLength()-1);
tempr=tempr+"]";
r.append(tempr);
}
r.append("}");
return r;
}else{
return "";
}
}
?2:界面把JSON传到后台
?????