日期:2014-05-16  浏览次数:20397 次

这个js的td属性是如何设定的
我在这里面写的td width对于新加的行完全无用  
<tbody id="ACE_HIDDEN_TABLE" style="display:one"> 这个display 可以设定为默认有一行或默认无行


默认显示一行的时候,然后增加一行


默认不显示行的时候,增加一行

我希望能够与上面的文字栏对齐 应该如何处理?


html代码如下
HTML code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style type="text/css">
<!--
table{border-collapse:collapse;border:none;} /*table改为细边框*/
td{border:solid #000 1px;}
-->
<!--
table input {
    border-top-width: 0px;   /*不用时使用这个方法注释掉*/
    border-right-width: 0px;  /*input去边框的方法*/
    border-bottom-width: 0px;
    border-left-width: 0px;
    border-top-style: dashed;
    border-right-style: dashed;
    border-bottom-style: dashed;
    border-left-style: dashed;
    border-top-color: #000000;
    border-right-color: #000000;
    border-bottom-color: #000000;
    border-left-color: #000000; 
}
-->
</style>
<script language="JavaScript"> 
var cGetRow=-99999;
function insertrow(){
var newrow = document.all.ACE_HIDDEN_TABLE.rows[0].cloneNode(true); //克隆一行
document.all("newTB").appendChild(newrow); //添加刚才克隆的一行
}
function GetRow(){
//获得行索引
//两个parentElement分别是TD和TR,rowIndex是TR的属性
//this.parentElement.parentElement.rowIndex
cGetRow=window.event.srcElement.parentElement.parentElement.rowIndex;

DelRow(cGetRow);//点击checkbox时,直接删除行。
}
function DelRow(iIndex){
//删除一行
if(iIndex==-99999){
alert("系统提示:没有选中行号!");
}else{
newTB.deleteRow(iIndex);
iIndex==-99999;//将rowIndex恢复默认值。
}
}
</script>
</head>

<body>

<form action="chuli.php" method="post">
<table>
<tr><td>名字</td></tr>
<tr><td><input type="text" name="name" /></td></tr>
</table>

<table border="1">
<tr>
    <td width="40">删除</td>
    <td width="40">登记</td>
    <td width="70">用户号码</td>
    <td width="150">建筑名称</td>
</tr>    

 <tbody id="ACE_HIDDEN_TABLE" style="display:one">
  <tr>
    <td width="40"><input type="checkbox" onclick="GetRow()"/></td>
    <td width="40"><input type="text" name="record[]" /></td>
    <td width="70"><input type="text" name="usercode[]" /></td>
    <td width="150"><input type="text" name="buildname[]" /></td>
  </tr>
</table>

<table width="1250" border="1">
<!-- 插入新行的区域 begin -->
<tbody id="newTB">
</tbody>
<!-- 插入新行的区域 end -->
</table>

<div align="center" style="margin:10px;">
<input type="button" onClick="insertrow();" value="增加一行">
<!--<input type="button" onClick="DelRow(cGetRow);" value="删除一行">-->
</div>
<input type="subm