<script>
function she(tablename){
var td = document.getElementById("td1");
alert(td.width); //为什么得不到这个系统自己生成的值
}
</script><table id="showTable">
<tr>
<td id ='td1' width='50'>序号</td>
<td>姓名</td>
<td>性别</td>
<td>级别</td>
</tr>
</table>
<input type="button" value="onclick" onclick="she('showTable')">
function she(tablename){
var td = document.getElementById("td1");
alert(td.width); //为什么得不到这个系统自己生成的值
}
</script><table id="showTable">
<tr>
<td id ='td1' width='50'>序号</td>
<td>姓名</td>
<td>性别</td>
<td>级别</td>
</tr>
</table>
<input type="button" value="onclick" onclick="she('showTable')">
<tr>
<td onmouseover='alert(offsetWidth)'>序号</td>
<td>姓名</td>
<td>性别</td>
<td>级别</td>
</tr>
</table>
<input type="button" value="onclick" onclick="she('showTable')"><script>
function she(tablename){
var obj = document.getElementById('showTable').rows[0].cells[1];
alert(obj.offsetWidth); //为什么得不到这个系统自己生成的值
}
</script>
================>
alert(td.offsetWidth);
<tr>
<td width="value">序号</td>
<td width="value">姓名</td>
<td width="value">性别</td>
<td width="value">级别</td>
</tr>
</table>
这个虽然麻烦,但是实在
function she(tablename){
var td=document.getElementById(tablename).rows[0].cells[1];
alert(td.clientWidth); //为什么得不到这个系统自己生成的值
}
</script><table id="showTable">
<tr>
<td>序号</td>
<td>姓名</td>
<td>性别</td>
<td>级别</td>
</tr>
</table>
<input type="button" value="onclick" onclick="she('showTable')">
但现在这样不行的.<html>
<SCRIPT LANGUAGE="JavaScript">
<!--
var rowCount=1; function addRow(tablename){
tr=document.all.item(tablename).insertRow();
cell=tr.insertCell(); // 编号
cell.innerHTML=rowCount; cell=tr.insertCell(); rowStr="<input type='text' size="+cell.clientWidth+">";
cell.innerHTML=rowStr; rowCount=rowCount+1;
} //-->
</SCRIPT> <body>
<form name="fm">
<input type="button" value="onclick" onclick="addRow('showTable')">
</form><table width="100%" border=1 align="center" cellSpacing=0 borderColorLight=#527DB5 BorderColorDark=#ffffff ID="showTable">
<tr>
<td nowrap>序号</td>
<td nowrap>值</td>
</tr>
</table></body>
</html>
rowStr="<input type='text' style='width:"+cell.clientWidth+"'>";
<SCRIPT LANGUAGE="JavaScript">
<!--
var rowCount=1; function addRow(tablename){
tr=document.all.item(tablename).insertRow();
cell=tr.insertCell();
cell.innerHTML=rowCount; cell=tr.insertCell(); rowStr="<input type='text' style='width:"+cell.clientWidth+"'>";
cell.innerHTML=rowStr; rowCount=rowCount+1;
} //-->
</SCRIPT> <body>
<form name="fm">
<input type="button" value="onclick" onclick="addRow('showTable')">
</form><table width="100%" border=1 align="center" cellSpacing=0 borderColorLight=#527DB5 BorderColorDark=#ffffff ID="showTable">
<tr>
<td nowrap>id</td>
<td nowrap>name</td>
</tr>
</table></body>
</html>
<SCRIPT LANGUAGE="JavaScript">
<!--
var rowCount=1; function addRow(tablename){
tr=document.all.item(tablename).insertRow();
cell=tr.insertCell();
cell.innerHTML=rowCount;
cell.style.width=cell.offsetWidth;
cell=tr.insertCell(); rowStr="<input type='text' style='width:"+(cell.clientWidth-2)+"'>";
cell.innerHTML=rowStr; rowCount=rowCount+1;
} //-->
</SCRIPT> <body>
<form name="fm">
<input type="button" value="onclick" onclick="addRow('showTable')">
</form><table width="100%" border=1 align="center" cellSpacing=0 borderColorLight=#527DB5 BorderColorDark=#ffffff ID="showTable">
<tr>
<td nowrap>id</td>
<td nowrap>name</td>
</tr>
</table></body>
</html>
qiqunet(瑞旗·广东)
大侠,两个是对的,可是当我三个的时候,去又不对了,谢谢了,再帮一次忙.<html>
<SCRIPT LANGUAGE="JavaScript">
<!--
var rowCount=1; function addRow(tablename){
tr=document.all.item(tablename).insertRow();
cell=tr.insertCell();
cell.innerHTML=rowCount;
cell.style.width=cell.offsetWidth; cell=tr.insertCell();
rowStr="<input type='text' style='width:"+(cell.clientWidth-2)+"'>";
cell.innerHTML=rowStr;
cell.style.width=cell.offsetWidth; cell=tr.insertCell();
rowStr="<input type='text' style='width:"+(cell.clientWidth-2)+"'>";
cell.innerHTML=rowStr;
rowCount=rowCount+1;
} //-->
</SCRIPT> <body>
<form name="fm">
<input type="button" value="onclick" onclick="addRow('showTable')">
</form><table width="100%" border=1 align="center" cellSpacing=0 borderColorLight=#527DB5 BorderColorDark=#ffffff ID="showTable">
<tr>
<td nowrap>id</td>
<td nowrap>name</td>
<td nowrap>value</td> </tr>
</table></body>
</html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<SCRIPT LANGUAGE="JavaScript">
<!--
var rowCount=1; function addRow(tablename){
var aa = document.getElementById("showTable");
var w1 = aa.rows[0].cells[0].clientWidth;
var w2 = aa.rows[0].cells[1].clientWidth;
var w3 = aa.rows[0].cells[2].clientWidth;
tr=document.all.item(tablename).insertRow();
cell=tr.insertCell();
cell.innerHTML=rowCount;
cell.style.width=w1; cell=tr.insertCell();
rowStr="<input type='text' style='width:99%'>";
cell.innerHTML=rowStr;
cell.style.width=w2; cell=tr.insertCell();
rowStr="<input type='text' style='width:99%'>";
cell.innerHTML=rowStr;
cell.style.width=w3; rowCount=rowCount+1;
} //-->
</SCRIPT>
</head>
<body>
<form name="fm">
<input type="button" value="onclick" onClick="addRow('showTable')">
</form>
<table width="100%" border=1 align="center" cellSpacing=0 borderColorLight=#527DB5 BorderColorDark=#ffffff ID="showTable">
<tr>
<td nowrap>id</td>
<td nowrap>name</td>
<td nowrap>value</td>
</tr>
</table>
</body>
</html>
cvpc(一回)的可以了,非常感谢!