`
tianqinghua
  • 浏览: 27933 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类

把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;
				}
					
              }

}
 
分享到:
评论

相关推荐

    Java中图形化报表实例

    总之,Java中图形化报表实例是学习数据可视化的宝贵资源,它涵盖了从数据获取、处理到前端展示的全过程,对于提升JavaWeb开发能力具有很大的帮助。通过深入理解和动手实践,你将能掌握这项技能,并在实际工作中...

    SpringBoot + Vue + ElementUI 实现一个后台管理系统模板.zip

    这个项目涵盖了从前后端开发到系统集成的全过程,对于IT专业的学生来说,是一个全面实践和巩固所学知识的好机会。通过这个项目,可以学习到如何将理论知识转化为实际应用,提升解决问题的能力。

    Video-Tutorial--MySQL-ANDROID.rar_android

    4. **JSON解析**:因为数据通常以JSON格式在客户端和服务器之间传输,所以会教授如何使用Gson或Jackson库来解析JSON。 5. **MySQL基础知识**:介绍如何创建MySQL数据库,定义表格,以及执行CRUD(Create、Read、...

    layui-后台模板jump-server.zip

    SpringBoot 是Java领域的一个热门微服务框架,它简化了传统Spring应用的初始设置和配置过程,提倡“约定优于配置”的原则,使得开发者可以更快地专注于业务逻辑的实现。在标签中提到"layui springboot",意味着这个...

    SpringBoot + Vue3.2 + Element Plus 微商城 SaaS 系统.zip

    本文将详细解析这一系统的核心技术和实现方式。 首先,SpringBoot作为Java领域的轻量级框架,以其快速启动、简化配置、内嵌Tomcat等优势,成为后端开发的首选。在本项目中,SpringBoot承担了服务端的主要职责,负责...

    史上最好传智播客就业班.net培训教程60G 不下会后悔

    数据库开发基础、Microsoft SQLServer基础、SQL语言基础、索引、事务、SQL语言高级技术(空值处理、聚合与分组、数据分页、Union、日期函数、类型转换函数、流控函数、表连接、子查询、存储过程、触发器)、数据库...

Global site tag (gtag.js) - Google Analytics