如何用JS取表格单元格的值以及如何给它赋值。表格、单元格的属性用的都是id,不是name
解决方案 »
- Ajax乱码,相当严重。
- 老师刚布置了个作业 关于字典表取值的 跪求大神们给点思路
- 关于Struts2下拉菜单的一个问题,求指教
- javaScript里怎么可以拿到applet里的方法
- 怎样将中内存中画好的图像,输出在jsp页面指定的位置。比如说,<td></td>内
- 乱码问题
- 问个问题
- WAR files' communication
- 提交的中文怎么成了 ???????
- 求教一个hibernate 的简单问题
- 请给我推荐几个开源购物商城的源码。
- Struts+Spring+Hibernate出错Batch update returned unexpected row count from update:0 actual row count: 7810893
難道document。getElementById?
還是document。forms【0】。字段名。value?
或者var xx = $F(‘字段名’)?
你到底要干什么?
就可以了
function makeTable() { var table = document.createElement("table"); table.setAttribute("border","1"); table.setAttribute("width","600"); table.setAttribute("class","tab-content"); document.body.appendChild(table); var header = table.createTHead(); var headerrow = header.insertRow(0); headerrow.insertCell(0).appendChild(document.createTextNode("姓名")); headerrow.insertCell(1).appendChild(document.createTextNode("职业")); headerrow.insertCell(2).appendChild(document.createTextNode("工资"));
for(var i=0;i<5;i++) { var row = table.insertRow(i+1); row.insertCell(0).appendChild(document.createTextNode("aaa")); row.insertCell(1).appendChild(document.createTextNode("bbb")); row.insertCell(2).appendChild(document.createTextNode("ccc"));
}} 调用 makeTable() 这个方法就可以创建一个 Table , 数据可以从 XML 或者 其他文件,数据库里将值取出来读取到表格中
先得到表格的对象 用 document.getElementById(tableid) 或 document.all.tableid 来获取
再定位到你要获取单元格 table.rows(i).cells(j).innerText
document.all.表格ID.rows[x].cells[x].innerHTML="";
x為數字型,