Script

本类阅读TOP10

·可编辑的 HTML JavaScript 表格控件 DataGrid II
·JavaScript通用库(一)
·一个简单的javascript菜单
·层遇到select框时
·javascript表单之间的数据传递!
·在网页中控制wmplayer播放器
·网站流量统计代码
·让网页自动穿上外套
·24点终结者(javascript)
·搜索gb2312汉字在网上的频率

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
怎样让你的表格可编辑???

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

 

怎样让你的表格可编辑???

出处:http://go.163.com/colorweb

欢迎光临 [孟宪会之精彩世界] http://lucky.myrice.com

代码如下:

<HTML> <HEAD> <STYLE> .td1 { color: white; background-color: orange;} .td2 { color: white; background-color: #0099ff;} .td3 { color: white; background-color: #336699;} </STYLE> <SCRIPT> function editCell (cell) { if (document.all) { cell.innerHTML = '<INPUT ID="editCell" ONCLICK="event.cancelBubble = true;" ONCHANGE="setCell(this.parentElement, this.value)" ONBLUR="setCell(this.parentElement, this.value)" VALUE="' + cell.innerText + '" SIZE="' + cell.innerText.length + '">'; document.all.editCell.focus(); document.all.editCell.select(); } else if (document.getElementById) { cell.normalize(); var input = document.createElement('INPUT'); input.setAttribute('value', cell.firstChild.nodeValue); input.setAttribute('size', cell.firstChild.nodeValue.length); input.onchange = function (evt) { setCell(this.parentNode, this.value); }; input.onclick = function (evt) { evt.cancelBubble = true; if (evt.stopPropagation) evt.stopPropagation(); }; cell.replaceChild(input, cell.firstChild); input.focus(); input.select(); } } function setCell (cell, value) { if (document.all) cell.innerText = value; else if (document.getElementById) cell.replaceChild(document.createTextNode(value), cell.firstChild); } </SCRIPT> </HEAD> <BODY> <TABLE BORDER="2"> <TR> <TD ONCLICK="editCell(this);" CLASS="td1">欢迎光临</TD> <TD ONCLICK="editCell(this);" CLASS="td2">[孟宪会之精彩世界]</TD> <TD ONCLICK="editCell(this);" CLASS="td3">http://lucky.myrice.com</TD> </TR> </TABLE> </BODY> </HTML>



相关文章

相关软件