<td><input type="text" name="fieldname"></td> <!-- <td > <input type="text" name="fielddisnamezh" ></td> <td > <input type="text" name="fielddisnametw" ></td> <td > <input type="text" name="fielddisnamejp" ></td> <td > <input type="text" name="fielddisnamefr" ></td> <td > <input type="text" name="fielddisnameen" ></td> --> <td><input type="text" name="description"></td> <td><input type="text" name="defaultvalue"></td> <td><input type="text" name="fieldtype"></td> <td><input type="text" name="fieldregex"></td> <td><a class="btn btn-xs btn-danger" href="#" onclick="del_tr(this)"> <i class="icon-trash icon-white"></i> 删除 </a></td>
getData = function(window,$){
var json = {};
var data=[];
var reg = /,+$/;
$("input[type=text]").each(function(){
var thisName = $(this).attr("name");
var thisVal = $(this).val();
data +=thisName+":"+thisVal+",";
});
data = data.replace(reg,'');
json = "{"+data+"}";
console.log(json);
}
var jsonData="[";
var table=document.getElementByID('table1');
for(var rowIndex=0;rowIndex<table.rows.length;rowIndex++){
jsonData+="{fieldname:table.rows[rowIndex].cells[0].innerHTML,";
jsonData+="{fieldname:table.rows[rowIndex].cells[1].innerHTML,";
jsonData+="{fieldname:table.rows[rowIndex].cells[2].innerHTML,";
jsonData+="{fieldname:table.rows[rowIndex].cells[3].innerHTML}";
}
jsonData="]";
没做测试。。。
function MyObject(name,old,email,phone){
this.name=name;
this.old=old;
this.email=email;
this.phone=phone;
}
var arrMyObject=new array();
for(var rowIndex=0;rowIndex<table.rows.length;rowIndex++){
var myobject=new MyObject(table.rows[rowIndex].cells[0].innerHTML,
table.rows[rowIndex].cells[0].innerHTML,table.rows[rowIndex].cells[0].innerHTML,
table.rows[rowIndex].cells[0].innerHTML,);
arrMyObject[rowIndex]=myobject;
}
var jsonData=JSON.stringify(arrMyObject);
//未测试
//什么水平别人不知道