javascript操作表格.doc_第1页
javascript操作表格.doc_第2页
javascript操作表格.doc_第3页
javascript操作表格.doc_第4页
javascript操作表格.doc_第5页
免费预览已结束,剩余5页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

javascript操作表格Sample (DHTML Dude)TR background-color: white; color: black; font-family: verdana; font-size: 20; font-weight: bold; Table Editor单击选择单元格,按下Alt键选择一行! Cell 1,1Cell 1,2Cell 1,3 Cell 2,1Cell 2,2Cell 2,3 Cell 3,1Cell 3,2Cell 3,3var lastSelection = null;ButtonAddRow.setExpression(disabled, nothingSelected(lastSelection);ButtonRemoveRow.setExpression(disabled, ! rowSelected(lastSelection);ButtonAddCell.setExpression(disabled, nothingSelected(lastSelection);ButtonRemoveCell.setExpression(disabled, ! cellSelected(lastSelection);ButtonMoveUp.setExpression(disabled, ! rowSelected(lastSelection);ButtonMoveDown.setExpression(disabled, ! rowSelected(lastSelection);ButtonMoveLeft.setExpression(disabled, ! cellSelected(lastSelection);ButtonMoveRight.setExpression(disabled, ! cellSelected(lastSelection);ButtonEditContents.setExpression(disabled, (! cellSelected(lastSelection) | (EditCell.style.display = );ButtonEditStyle.setExpression(disabled, (EditStyle.style.display = );ButtonEditStyle.setExpression(value, Edit + whatIsSelected(lastSelection) + Style);function select(element) var e, r, c;if (element = null) e = window.event.srcElement; else e = element;if (window.event.altKey) | (e.tagName = TR) r = findRow(e); if (r != null) if (lastSelection != null) deselectRowOrCell(lastSelection); selectRowOrCell(r); lastSelection = r; else c = findCell(e); if (c != null) if (lastSelection != null) deselectRowOrCell(lastSelection); selectRowOrCell(c); lastSelection = c; window.event.cancelBubble = true; TableContainer.onclick = select;function cancelSelect() if (window.event.srcElement.tagName != BODY) return;if (lastSelection != null) deselectRowOrCell(lastSelection); lastSelection = null;document.onclick = cancelSelect;function findRow(e) if (e.tagName = TR) return e; else if (e.tagName = BODY) return null; else return findRow(e.parentElement);function findCell(e) if (e.tagName = TD) return e; else if (e.tagName = BODY) return null; else return findCell(e.parentElement);function deselectRowOrCell(r) r.runtimeStyle.backgroundColor = ;r.runtimeStyle.color = ;/r.runtimeStyle.fontFamily = Verdana;function selectRowOrCell(r) r.runtimeStyle.backgroundColor = darkblue;r.runtimeStyle.color = white;/r.runtimeStyle.fontFamily = Verdana;function addRow() var r, p, nr;if (lastSelection = null) r = null; p = TheTable.children0; else r = lastSelection; if (r.tagName = TD) r = r.parentElement; p = r.parentElement;nr = document.createElement(TR);p.insertBefore(nr, r);select(nr);addCell();return nr; function removeRow() var r, p, nr;if (lastSelection = null) return false;r = lastSelection;if (r.tagName = TD) r = r.parentElement;p = r.parentElement;p.removeChild(r);lastSelection = null;return r; function addCell() var r, p, c, nc, text;if (lastSelection = null) return false;r = lastSelection;if (r.tagName = TD) r = r.parentElement; c = lastSelection; else c = null;nc = document.createElement(TD);text = document.createTextNode(New Cell);nc.insertBefore(text, null);r.insertBefore(nc, c);select(nc);return nc;function removeCell() var c, p, nr;if (lastSelection = null) return false;c = lastSelection;if (c.tagName != TD) return null;p = c.parentElement;p.removeChild(c);lastSelection = null;return c; function editContents() var c, p, nr;if (lastSelection = null) return false;c = lastSelection;if (c.tagName != TD) return null;EditCell.style.display = ;EditCell.value = c.innerHTML;c.setExpression(innerHTML, EditCell.value);EditCell.focus();EditCell.onblur = unhookContentsExpression;function unhookContentsExpression() lastSelection.removeExpression(innerHTML);EditCell.value = ;EditCell.style.display = none;function editStyle() var c;if (lastSelection = null) c = TheTable; else c = lastSelection;EditStyle.style.display = ;EditStyle.value = c.style.cssText;c.style.setExpression(cssText, EditStyle.value);EditStyle.focus();EditStyle.onblur = unhookStyleExpression;function unhookStyleExpression() var c;if (lastSelection = null) c = TheTable; else c = lastSelection;c.style.removeExpression(cssText);EditStyle.value = ;EditStyle.style.display = none;function moveUp() var r, p, ls;if (lastSelection = null) return false;r = lastSelection;if (r.tagName != TR) return null;if (r.rowIndex = 0) return;ls = r.previousSibling;p = ls.parentElement;p.insertBefore(r, ls);return r;function moveDown() var r, p, ls;if (lastSelection = null) return false;r = lastSelection;if (r.tagName != TR) return null;ls = r.nextSibling;if (ls = null) return null;p = ls.parentElement;ls = ls.nextSibling;p.insertBefore(r, ls);return r;function moveLeft() var c, p, ls;if (lastSelection = null) return false;c = lastSelection;if (c.tagName != TD) return null;ls = c.previousSibling;if (ls = null) return null;p = ls.parentElement;p.insertBefore(c, ls);return c;function moveRight() var c, p, ls;if (lastSelection = null) return false;c = lastSelection;if (c.tagName != TD) return null;ls = c.nextSibling;if (ls = null) return null;p = ls.parentElement;ls = ls.nextSibling;p.insertBefore(c, ls);return c;function nothingSelected() return (lastSelection = null);function rowSelected() var c;if (lastSelection = null) return false;c = lastSelection;return (c.tag

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论