looyx 2016-11-25 14:54 采纳率: 33.3%
浏览 1327

js函数值怎么写到表格中去




下面这个代码通过document.getElementById("cd1").innerText = gaodu-40;把值填到第一个单元格,如果我想填到所有单元格,并且表格外面也要几个,应该怎么做


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
    function jisuan(){
    var gaodu = document.getElementById("gd").value;
    var kuandu = document.getElementById("kd").value;
    var shuliang = document.getElementById("sl").value;
    document.getElementById("cd1").innerText = gaodu-40;
  }</script>
</head>
<body onload="jisuan(this)" >
<form id="form1" name="form1" method="post" action="">
        高度
          <input type="text" id="gd" value="1600" />
        宽度<input type="text" id="kd" value="600" />
        数量<input type="text" id="sl" value="1" /><input type="button" onClick="jisuan(this)" value="计算" />
</form>
<table width="200" border="1">
  <tr>
    <td id="cd1">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>


</body>
</html>
  • 写回答

6条回答 默认 最新

  • threenewbee 2016-11-25 15:54
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮