<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()">
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()">
解决方案 »
- frameset的frame的resize事件问题
- 实在没办法了,请各位高手帮忙看下:为什么图片切换没有效果?(document.all和document.form)
- myshell.Run('cd D: \\php_code\\abc\\');请问这句话要怎么改?
- 奇怪的问题,让JS代码失效
- 监视iframe的onload事件
- 如何才能使下拉菜单向左侧伸展?
- 急,帮忙!
- 两个问题100分 !!在线等待!!请帮忙。
- ???怎样重定向到指定页面?
- 请问如何将一个字符转化成为ACSII码值(比如A)转换为ACSII码值(A对应的是65)?
- 请问javascripts的list有没有contains方法?
- 使用A链接中使用javascript:window.location.reload的疑问
例如:
<B><B><B></B></B></B><html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[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,table_width,all_width,all_height,table_type){
//参数含?(??的数?,横坐?,?坐?,柱子的厚度,柱子的?度,?表的?度,?表的高度,?表的?型)
var tmdColor1 = new Array();
tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";
var tmdColor2 = new Array();
tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";
var tb_color = new Array(tmdColor1,tmdColor2);
var line_color = "#69f";
var left_width = 70;
var length = thickness/2;
var total_no = total[0].length;
var temp1 = 0;
var temp2,temp3,temp4;
for(var i = 0;i<total_no;i++)
{
if(temp1<total[0][i])
{
temp1 = total[0][i];
}
}
temp1 = parseInt(temp1.toString());
if(temp1>9)
{
temp2 = temp1.toString().substr(1,1)
if(temp2>4)
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+1)*Math.pow(10,(temp1.toString().length-1));
}
else
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+0.5)*Math.pow(10,(temp1.toString().length-1));
}
}
else
{
if(temp1>4)
temp3 = 10;
else
temp3 = 5;
}
temp4=temp3
document.write("<!--[if gte vml 1]><v:rect id='_x0000_s1027' alt='' style='position:absolute;left:" + (table_x+left_width) + "px;top:" + table_y + "px;width:" + all_width + "px;height:" + all_height + "px;z-index:-1' fillcolor='#9cf' stroked='f'><v:fill rotate='t' angle='-45' focus='100%' type='gradient'/></v:rect><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + (table_y+all_height) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + table_y + "px' to='" + (table_x+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");switch (table_type)
{
case "A":
var table_space = (all_width-table_width*total_no)/total_no;
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px,"+ table_y + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-length) + "px' strokecolor='" + line_color + "'/><![endif]-->");
for(var i=0;i<=all_height-1;i+= all_height/5)
{
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width)+ "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-i) +"px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height-length-i) + "px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+(left_width-15)) + "px," + (table_y+i) + "px' to='" + (table_x+left_width) + "px," + (table_y+i) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + table_x + "px;top:" + (table_y+i) + "px;width:" + left_width + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>" + temp4 + "</td></tr></table></v:textbox></v:shape><![endif]-->");
temp4 = temp4-temp3/5;
}
for(var i=0;i<total_no;i++)
{
var temp_space = table_x + left_width + table_space / 2 + table_space * i + table_width * i;
document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
document.write(temp_space);
document.write("px;top:");
document.write(table_y + all_height * (1 - (total[0][i] / temp3)));
document.write("px;width:" + table_width + "px;height:" + all_height * (total[0][i] / temp3) + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' type='gradient'/>")
document.write("<o:extrusion v:ext='view' backdepth='" + thickness + "pt' color='" + tb_color[1][i] + "' on='t'/>");
document.write("</v:rect>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + temp_space + "px;top:" + (table_y+all_height*(1-(total[0][i]/temp3))-table_width) + "px;width:" + (table_space+15) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (temp_space-table_space/2) + "px;top:" + (table_y+all_height+1) + "px;width:" + (table_space+table_width) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
}
break;
</script>
<style>
TD { FONT-SIZE: 9pt}
</style>
</head>
<body topmargin=5 leftmargin=0 scroll=AUTO><script language=javascript>
var nameArray = new Array();
var dataArray = new Array();
fnccheck();
var total= new Array(dataArray,nameArray) ;
table1(total,200,20,20,30,400,200,"A");
table1(total,200,320,20,20,400,250,"B");</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> </body>
</html>
例如:
<B><B><B></B></B></B><html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[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,table_width,all_width,all_height,table_type){
//参数含?(??的数?,横坐?,?坐?,柱子的厚度,柱子的?度,?表的?度,?表的高度,?表的?型)
var tmdColor1 = new Array();
tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";
var tmdColor2 = new Array();
tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";
var tb_color = new Array(tmdColor1,tmdColor2);
var line_color = "#69f";
var left_width = 70;
var length = thickness/2;
var total_no = total[0].length;
var temp1 = 0;
var temp2,temp3,temp4;
for(var i = 0;i<total_no;i++)
{
if(temp1<total[0][i])
{
temp1 = total[0][i];
}
}
temp1 = parseInt(temp1.toString());
if(temp1>9)
{
temp2 = temp1.toString().substr(1,1)
if(temp2>4)
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+1)*Math.pow(10,(temp1.toString().length-1));
}
else
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+0.5)*Math.pow(10,(temp1.toString().length-1));
}
}
else
{
if(temp1>4)
temp3 = 10;
else
temp3 = 5;
}
temp4=temp3
document.write("<!--[if gte vml 1]><v:rect id='_x0000_s1027' alt='' style='position:absolute;left:" + (table_x+left_width) + "px;top:" + table_y + "px;width:" + all_width + "px;height:" + all_height + "px;z-index:-1' fillcolor='#9cf' stroked='f'><v:fill rotate='t' angle='-45' focus='100%' type='gradient'/></v:rect><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + (table_y+all_height) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + table_y + "px' to='" + (table_x+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");switch (table_type)
{
case "A":
var table_space = (all_width-table_width*total_no)/total_no;
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px,"+ table_y + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-length) + "px' strokecolor='" + line_color + "'/><![endif]-->");
for(var i=0;i<=all_height-1;i+= all_height/5)
{
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width)+ "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-i) +"px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height-length-i) + "px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+(left_width-15)) + "px," + (table_y+i) + "px' to='" + (table_x+left_width) + "px," + (table_y+i) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + table_x + "px;top:" + (table_y+i) + "px;width:" + left_width + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>" + temp4 + "</td></tr></table></v:textbox></v:shape><![endif]-->");
temp4 = temp4-temp3/5;
}
for(var i=0;i<total_no;i++)
{
var temp_space = table_x + left_width + table_space / 2 + table_space * i + table_width * i;
document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
document.write(temp_space);
document.write("px;top:");
document.write(table_y + all_height * (1 - (total[0][i] / temp3)));
document.write("px;width:" + table_width + "px;height:" + all_height * (total[0][i] / temp3) + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' type='gradient'/>")
document.write("<o:extrusion v:ext='view' backdepth='" + thickness + "pt' color='" + tb_color[1][i] + "' on='t'/>");
document.write("</v:rect>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + temp_space + "px;top:" + (table_y+all_height*(1-(total[0][i]/temp3))-table_width) + "px;width:" + (table_space+15) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (temp_space-table_space/2) + "px;top:" + (table_y+all_height+1) + "px;width:" + (table_space+table_width) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
}
break;
</script>
<style>
TD { FONT-SIZE: 9pt}
</style>
</head>
<body topmargin=5 leftmargin=0 scroll=AUTO><script language=javascript>
var nameArray = new Array();
var dataArray = new Array();
fnccheck();
var total= new Array(dataArray,nameArray) ;
table1(total,200,20,20,30,400,200,"A");
table1(total,200,320,20,20,400,250,"B");</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> </body>
</html>
程序如下:<B><B><B></B></B></B><html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[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,table_width,all_width,all_height,table_type){
//参数含?(??的数?,横坐?,?坐?,柱子的厚度,柱子的?度,?表的?度,?表的高度,?表的?型)
var tmdColor1 = new Array();
tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";
var tmdColor2 = new Array();
tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";
var tb_color = new Array(tmdColor1,tmdColor2);
var line_color = "#69f";
var left_width = 70;
var length = thickness/2;
var total_no = total[0].length;
var temp1 = 0;
var temp2,temp3,temp4;
for(var i = 0;i<total_no;i++)
{
if(temp1<total[0][i])
{
temp1 = total[0][i];
}
}
temp1 = parseInt(temp1.toString());
if(temp1>9)
{
temp2 = temp1.toString().substr(1,1)
if(temp2>4)
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+1)*Math.pow(10,(temp1.toString().length-1));
}
else
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+0.5)*Math.pow(10,(temp1.toString().length-1));
}
}
else
{
if(temp1>4)
temp3 = 10;
else
temp3 = 5;
}
temp4=temp3
document.write("<!--[if gte vml 1]><v:rect id='_x0000_s1027' alt='' style='position:absolute;left:" + (table_x+left_width) + "px;top:" + table_y + "px;width:" + all_width + "px;height:" + all_height + "px;z-index:-1' fillcolor='#9cf' stroked='f'><v:fill rotate='t' angle='-45' focus='100%' type='gradient'/></v:rect><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + (table_y+all_height) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + table_y + "px' to='" + (table_x+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");switch (table_type)
{
case "A":
var table_space = (all_width-table_width*total_no)/total_no;
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px,"+ table_y + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-length) + "px' strokecolor='" + line_color + "'/><![endif]-->");
for(var i=0;i<=all_height-1;i+= all_height/5)
{
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width)+ "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-i) +"px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height-length-i) + "px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+(left_width-15)) + "px," + (table_y+i) + "px' to='" + (table_x+left_width) + "px," + (table_y+i) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + table_x + "px;top:" + (table_y+i) + "px;width:" + left_width + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>" + temp4 + "</td></tr></table></v:textbox></v:shape><![endif]-->");
temp4 = temp4-temp3/5;
}
for(var i=0;i<total_no;i++)
{
var temp_space = table_x + left_width + table_space / 2 + table_space * i + table_width * i;
document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
document.write(temp_space);
document.write("px;top:");
document.write(table_y + all_height * (1 - (total[0][i] / temp3)));
document.write("px;width:" + table_width + "px;height:" + all_height * (total[0][i] / temp3) + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' type='gradient'/>")
document.write("<o:extrusion v:ext='view' backdepth='" + thickness + "pt' color='" + tb_color[1][i] + "' on='t'/>");
document.write("</v:rect>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + temp_space + "px;top:" + (table_y+all_height*(1-(total[0][i]/temp3))-table_width) + "px;width:" + (table_space+15) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (temp_space-table_space/2) + "px;top:" + (table_y+all_height+1) + "px;width:" + (table_space+table_width) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
}
break;
}
</script>
<style>
TD { FONT-SIZE: 9pt}
</style>
</head>
<body topmargin=5 leftmargin=0 scroll=AUTO><script language=javascript>
var nameArray = new Array();
var dataArray = new Array();
fnccheck();
var total= new Array(dataArray,nameArray) ;
table1(total,200,20,20,30,400,200,"A");
table1(total,200,320,20,20,400,250,"B");</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> </body>
</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,table_width,all_width,all_height,table_type){
//参数含?(??的数?,横坐?,?坐?,柱子的厚度,柱子的?度,?表的?度,?表的高度,?表的?型)
var tmdColor1 = new Array();
tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";
var tmdColor2 = new Array();
tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";
var tb_color = new Array(tmdColor1,tmdColor2);
var line_color = "#69f";
var left_width = 70;
var length = thickness/2;
var total_no = total[0].length;
var temp1 = 0;
var temp2,temp3,temp4;
for(var i = 0;i<total_no;i++)
{
if(temp1<total[0][i])
{
temp1 = total[0][i];
}
}
temp1 = parseInt(temp1.toString());
if(temp1>9)
{
temp2 = temp1.toString().substr(1,1)
if(temp2>4)
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+1)*Math.pow(10,(temp1.toString().length-1));
}
else
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+0.5)*Math.pow(10,(temp1.toString().length-1));
}
}
else
{
if(temp1>4)
temp3 = 10;
else
temp3 = 5;
}
temp4=temp3
document.write("<!--[if gte vml 1]><v:rect id='_x0000_s1027' alt='' style='position:absolute;left:" + (table_x+left_width) + "px;top:" + table_y + "px;width:" + all_width + "px;height:" + all_height + "px;z-index:-1' fillcolor='#9cf' stroked='f'><v:fill rotate='t' angle='-45' focus='100%' type='gradient'/></v:rect><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + (table_y+all_height) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + table_y + "px' to='" + (table_x+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");switch (table_type)
{
case "A":
var table_space = (all_width-table_width*total_no)/total_no;
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px,"+ table_y + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-length) + "px' strokecolor='" + line_color + "'/><![endif]-->");
for(var i=0;i<=all_height-1;i+= all_height/5)
{
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width)+ "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-i) +"px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height-length-i) + "px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+(left_width-15)) + "px," + (table_y+i) + "px' to='" + (table_x+left_width) + "px," + (table_y+i) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + table_x + "px;top:" + (table_y+i) + "px;width:" + left_width + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>" + temp4 + "</td></tr></table></v:textbox></v:shape><![endif]-->");
temp4 = temp4-temp3/5;
}
for(var i=0;i<total_no;i++)
{
var temp_space = table_x + left_width + table_space / 2 + table_space * i + table_width * i;
document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
document.write(temp_space);
document.write("px;top:");
document.write(table_y + all_height * (1 - (total[0][i] / temp3)));
document.write("px;width:" + table_width + "px;height:" + all_height * (total[0][i] / temp3) + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' type='gradient'/>")
document.write("<o:extrusion v:ext='view' backdepth='" + thickness + "pt' color='" + tb_color[1][i] + "' on='t'/>");
document.write("</v:rect>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + temp_space + "px;top:" + (table_y+all_height*(1-(total[0][i]/temp3))-table_width) + "px;width:" + (table_space+15) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (temp_space-table_space/2) + "px;top:" + (table_y+all_height+1) + "px;width:" + (table_space+table_width) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
}
break;
}
}</script>
<style>
TD { FONT-SIZE: 9pt}
</style>
</head>
<body topmargin=5 leftmargin=0 scroll=AUTO>
<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> </body>
</html> <script language=javascript>
var nameArray = new Array();
var dataArray = new Array();
fnccheck();
var total= new Array(dataArray,nameArray) ;
table1(total,200,20,20,30,400,200,"A");
table1(total,200,320,20,20,400,250,"B");
</script>
var nameArray = new Array();
var dataArray = new Array();
fnccheck();
var total= new Array(dataArray,nameArray) ;
table1(total,200,20,20,30,400,200,"A");
table1(total,200,320,20,20,400,250,"B");
</script>
你在上面的代码调用了fnccheck();这个方法,而这个方法要用到table对象,由于html页面是从上到下顺序加载的,所以,你写在前面的时候table对象还没有产生呢。