<meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><br /><table border="1" style="border-collapse: collapse" width="45%" height="29" id="table1"><tr><td> <input type="checkbox" name="C1" value="ON"></td><td>指令碼之家</td><td>www.jb51.net</td></tr><tr><td> <input type="checkbox" name="C2" value="ON"></td><td>百度</td><td>www.baidu.com</td></tr><tr><td> <input type="checkbox" name="C3" value="ON"></td><td>伺服器軟體</td><td>s.jb51.net</td></tr></table><p><input type="button" onclick="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