当前位置: 代码迷 >> HTML/CSS >> 把HTML报表的内容保存为JSON格式以及JAVA后台解析全过程
  详细解决方案

把HTML报表的内容保存为JSON格式以及JAVA后台解析全过程

热度:106   发布时间:2012-09-29 10:30:01.0
把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[number-j];
  			     }
  			     //var arrayObject1= new Array();
  			     var strObj="[";
  				 for(var i=0;i<json1.length;i++){
  				 	 var arrayObject=new Array(i);
  				 	strObj+="{childId:'"+json1[i][0]+
  				 		"',name:'"+json1[i][1]+
  						"',youHui:'"+json1[i][2]+
  						"',eduType:'"+json1[i][3]+
  						"',edDaiMa:'"+json1[i][4]+
  						"',youHuiEd:'"+json1[i][5]+
  						"',youHuiFs:'"+json1[i][6]+
  						"',mostPrice:'"+json1[i][7]+
						"',edDaiMaStates:'"+json1[i][8]+
						"',youHuiFsStatues:'"+json1[i][9]+
						"',edDaiMaText:'"+json1[i][10]+
						"',eduTypeText:'"+json1[i][11]+
						"',voucher_code:'"+json1[i][12];
  						if(i==json1.length-1){
  							strObj+="'}";	
  						}else{
  							strObj+="'},";	
  						}

  				 	}
  				 strObj+="]";
  				 var rst = eval("{" + strObj + "}");
  				 o.json=rst;
				}
					
              }

}
?
  相关解决方案