日期:2014-05-17  浏览次数:20581 次

把HTML表格的内容保存为JSON格式以及JAVA后台解析全过程!
function savePanelData(){
      	var o=parent.get("SNPromotionVoucherData",null);
        var ot = document.getElementById("selectColor");//表格对象
        var voucherChildId=new Array();//单品的catentry_id和partnumber和在一起
        var productName=new Array();
        var youHui=new Array();
        var eduType=new Array();
        var eduTypeText=new Array();
        var edDaiMa=new Array();  
        var edDaiMaText=new Array();  
        var edDaiMaStates=new Array();  
        var youHuiEd=new Array();
        var youHuiFs=new Array(); 
        var youHuiFsStatues=new Array();
        var mostPrice=new Array(); 
        var credence=new Array();
        	if(parent.get){
        		 var o=parent.get("SNPromotionVoucherData",null);
                 if (o != null) {
                 	 // 满的场合,动态列表长度
     	            o.tableSize=ot.rows.length; 
     	            // 满的场合,动态列表值的存放
     	           for (var i = 1 ; i < ot.rows.length; i++ ) {
     	           		voucherChildId[i-1] = ot.rows(i).cells(0)["innerText"];
     	           	    productName[i-1] = ot.rows(i).cells(1)["innerText"];
     	           		youHui[i-1] = ot.rows(i).cells(2).children[0].options[ot.rows(i).cells(2).children[0].selectedIndex].value;
     	           		eduType[i-1]= ot.rows(i).cells(3).children[0].options[ot.rows(i).cells(3).children[0].selectedIndex].value;
     	           		eduTypeText[i-1]= ot.rows(i).cells(3).children[0].options[ot.rows(i).cells(3).children[0].selectedIndex].innerHTML;
     	            	edDaiMa[i-1]=ot.rows(i).cells(4).children[0].options[ot.rows(i).cells(4).children[0].selectedIndex].value;
     	            	edDaiMaStates[i-1]=ot.rows(i).cells(4).children[0].disabled;
     	            	edDaiMaText[i-1] = ot.rows(i).cells(4).children[0].options[ot.rows(i).cells(4).children[0].selectedIndex].innerHTML
     	            	youHuiEd[i-1] = ot.rows(i).cells(5).children[0].value;
     	            	youHuiFs[i-1]=ot.rows(i).cells(6).children[0].options[ot.rows(i).cells(6).children[0].selectedIndex].value;
     	            	youHuiFsStatues[i-1] = ot.rows(i).cells(6).children[0].disabled;
     	            	mostPrice[i-1]=ot.rows(i).cells(7).children[0].value;
     	            	credence[i-1]=ot.rows(i).cells(8).children[0].value;
     	           }
     	            o.voucherChildId=voucherChildId;//编码
     	            o.productName=productName;//商品名称
     	            o.youHui=youHui;//优惠单类别
     	            o.eduType=eduType;//额度类型
     	            o.eduTypeText=eduTypeText;
     	            o.edDaiMa=edDaiMa;//额度代码
     	            o.edDaiMaStates=edDaiMaStates;//额度状态
     	            o.edDaiMaText=edDaiMaText;//额度代码文本
     	            o.youHuiEd=youHuiEd;//优惠额度
     	            o.youHuiFs=youHuiFs;//优惠方式
     	            o.youHuiFsStatues=youHuiFsStatues;//优惠方式状态
     	            o.mostPrice=mostPrice;//最大折扣
     	            o.voucher_code=credence;
     	            o.temp=temp;
     	            o.number=document.getElementById("number").value;
     	          	o.memoy=document.getElementById("memoy").value;
     	           var json1=new Array();
  				 var number=o.tableSize-1;
  			     for(var j=number;j>0;j--){
  			     	json1[number-j]=new Array();
  			     	json1[number-j][0]= o.voucherChildId[number-j];
  			     	json1[number-j][1]= o.productName[number-j];
  			     	json1[number-j][2]= o.youHui[number-j];
  			     	json1[number-j][3]= o.eduType[number-j];
  			     	json1[number-j][4]= o.edDaiMa[number-j];
  			     	json1[number-j][5]= o.youHuiEd[number-j];
  			     	json1[number-j][6]= o.youHuiFs[number-j];
  			     	json1[number-j][7]= o.mostPrice[number-j];
  			     	json1[number-j][8]= o.edDaiMaStates[number-j];
  			     	json1[number-j][9]= o.youHuiFsStatues[number-j];
  			     	json1[number-j][10]= o.edDaiMaText[number-j];
  			     	json1[number-j][11]=o.eduTypeText[number-j]
  			     	json1[number-j][12]=o.voucher_code