请问高手javascript读取table中数据如何赋值给数组!
<script language=javascript>
function fnccheck()
{
t=document.getElementById( "dg ")
var nameArray=new Array();
nameArray[0] =t.rows[0].cells[0].innerText;
var dataArray()=new Array();
dataArray[0]=t.rows[1].cells[0].innerText;
}
</script>
<table id=dg border =1>
<tr>
<td > a1 </td>
<td > a2 </td>
<td > a3 </td>
<td > a4 </td>
<td > a5 </td>
</tr>
<tr>
<td > 28 </td>
<td> 12 </td>
<td > 33 </td>
<td > 25 </td>
<td > 44 </td>
</tr>
</table>
请问高手,以上程序为何不能将值赋给数组,并且可以使用数组得值!多谢了!!!
------解决方案-------------------- <script language=javascript>
function fnccheck()
{
t=document.getElementById( "dg ")
var nameArray=new Array();
nameArray[0] =t.rows[0].cells[0].innerText;
var dataArray=new Array();
dataArray[0]=t.rows[1].cells[0].innerText;
alert(nameArray)
alert(dataArray)
}
</script>
<table id=dg border =1>
<tr>
<td > a1 </td>
<td > a2 </td>
<td > a3 </td>
<td > a4 </td>
<td > a5 </td>
</tr>
<tr>
<td > 28 </td>
<td> 12 </td>
<td > 33 </td>
<td > 25 </td>
<td > 44 </td>
</tr>
</table>
<input type= "button " onclick= "fnccheck() ">
------解决方案--------------------要调用 fnccheck()
------解决方案--------------------是不是这样子
<html>
<!--[if !mso]>
<style>
v\:* { behavior: url(#default#VML) }
o\:* { behavior: url(#default#VML) }
.shape { behavior: url(#default#VML) }
</style>
<![endif]-->
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> </title>
<script language=javascript>
function fnccheck()
{
t=document.getElementById( "dg ")
nameArray[0] =t.rows[0].cells[0].innerText;
dataArray[0]=t.rows[1].cells[0].innerText;
}
function table1(total,table_x,table_y,thickness,ta