www.u8686.com-信息发布平台
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>222222 </title>
</head>
<body>
<table border="1" style="border-collapse: collapse" width="45%" height="29" id="table1">
<tr>
<td> <input type="checkbox" name="C1" value="ON"> </td>
<td>222222 </td>
<td>222 </td>
</tr>
<tr>
<td> <input type="checkbox" name="C2" value="ON"> </td>
<td>233323 </td>
<td>1111 </td>
</tr>
<tr>
<td> <input type="checkbox" name="C3" value="ON"> </td>
<td>123123 </td>
<td>1222 </td>
</tr>
</table>
<input type="button" οnclick="readArray()" value="取得表格值">
<script>
//使用数组取得表格值
function getRowText()
{
var arr = new Array();
var count = 0;
for(var i=0;i <table1.rows.length;i++)
{
var row = table1.rows[i];
//取得CHECKBOX
var objCheck = row.cells[0].getElementsByTagName("INPUT")[0];
//如果CHECKBOX被选中.添加到二维数组
if(objCheck!=null && objCheck.checked)
{
//arr[i]= row.innerText ;
arr[count] = new Array();
for(var x=0;x <row.cells.length;x++)
{
//不计单选框的单元格内容
if(x==0) continue;
arr[count][x-1] = row.cells[x].innerText;
}
count++;
}
}
return arr;
}
//读取表格值
function readArray()
{
var arr = getRowText();
for(var i=0;i <arr.length;i++)
{
//取得每一行的值
for(var x= 0;x <arr[i].length;x++)
{
document.write(arr[i][x]);
}
}
}
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>222222 </title>
</head>
<body>
<table border="1" style="border-collapse: collapse" width="45%" height="29" id="table1">
<tr>
<td> <input type="checkbox" name="C1" value="ON"> </td>
<td>222222 </td>
<td>222 </td>
</tr>
<tr>
<td> <input type="checkbox" name="C2" value="ON"> </td>
<td>233323 </td>
<td>1111 </td>
</tr>
<tr>
<td> <input type="checkbox" name="C3" value="ON"> </td>
<td>123123 </td>
<td>1222 </td>
</tr>
</table>
<input type="button" οnclick="readArray()" value="取得表格值">
<script>
//使用数组取得表格值
function getRowText()
{
var arr = new Array();
var count = 0;
for(var i=0;i <table1.rows.length;i++)
{
var row = table1.rows[i];
//取得CHECKBOX
var objCheck = row.cells[0].getElementsByTagName("INPUT")[0];
//如果CHECKBOX被选中.添加到二维数组
if(objCheck!=null && objCheck.checked)
{
//arr[i]= row.innerText ;
arr[count] = new Array();
for(var x=0;x <row.cells.length;x++)
{
//不计单选框的单元格内容
if(x==0) continue;
arr[count][x-1] = row.cells[x].innerText;
}
count++;
}
}
return arr;
}
//读取表格值
function readArray()
{
var arr = getRowText();
for(var i=0;i <arr.length;i++)
{
//取得每一行的值
for(var x= 0;x <arr[i].length;x++)
{
document.write(arr[i][x]);
}
}
}
</script>
</body>
</html>