javascript如何实现动态填充html里table里的内容呢
javascript怎么实现动态填充html里table里的内容呢?
刚刚被领导逼着弄公司里的嵌入式WEB维护,现在在自学javascript,
------解决方案--------------------
1.你的程序只能在IE运行
2.按钮点击无效,是因为onclick="setTd()" setTd这个方法没有
修改如下:使用IE,点击读取,rtu这个位置会更新为2013-08-08
------解决方案--------------------
JS代码没有写在function里。LZ的写法是页面加载时执行。要使点击生效,应该写function
------解决方案--------------------
刚刚被领导逼着弄公司里的嵌入式WEB维护,现在在自学javascript,
------解决方案--------------------
1.你的程序只能在IE运行
2.按钮点击无效,是因为onclick="setTd()" setTd这个方法没有
修改如下:使用IE,点击读取,rtu这个位置会更新为2013-08-08
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>this is a test web</title>
</head>
<body>
<h4 align="center">事件记录</h4>
<table id="table1" width="600" border="1px" bordercolor="#000000" cellspacing="0px" style="border-collapse:collapse" align="center">
<tr>
<th>时间</th>
<th>设备</th>
<th>事项</th>
</tr>
<tr>
<td>2013-09-09</td>
<td>rtu</td>
<td>reboot</td>
</tr>
</table>
<!-- This is a comment start -->
<script type="text/javascript">
<!--
function setTd(){
document.getElementById('table1').rows(1).cells(1).innerHTML="2013-08-08";
}
//-->
</script>
<!-- This is a comment end -->
<input type="button" value="读取" onclick="setTd()">
</body>
</html>
------解决方案--------------------
JS代码没有写在function里。LZ的写法是页面加载时执行。要使点击生效,应该写function
function setTd() {
document.getElementById('table1').rows(1).cells(1).innerHTML="2013-08-08";
}
------解决方案--------------------
<!DOCTYPE html>
<html>
<head>
<title>this is a test web</title>
</head>
<body>
<h4 align="center">事件记录</h4>
<table id="table1" width="600" border="1px" bordercolor="#000000" cellspacing="0px" style="border-collapse:collapse" align="center">
<tr>
<th>时间</th>
<th>设备</th>
<th>事项</th>
</tr>
<tr>
<td>2013-09-09</td>
<td>rtu</td>
<td>reboot</td>
</tr>
</table>