📄 js_top.htm
字号:
if (oTable.rows.length==1
||nRowIndex2Del==null
||nRowIndex2Del==0
|| nRowIndex2Del>=oTable.rows.length)
return;
else
oTable.deleteRow(nRowIndex2Del);
}
function MoveUp(oTable,nRowIndex2Move)
{
//判断移动的行是否合法
if(nRowIndex2Move==null
|| nRowIndex2Move<=1
|| nRowIndex2Move>=oTable.rows.length)return;
ChangeRow(oTable,nRowIndex2Move,--nRowIndex2Move);
}
//向下移动指定表格的行
function MoveDown(oTable,nRowIndex2Move)
{
//判断移动的行是否合法
if(nRowIndex2Move==null
|| currentRowIndex==oTable.rows.length
|| currentRowIndex==0)
return;
ChangeRow(oTable,nRowIndex2Move,++nRowIndex2Move);
}
//指定表单的两行互换
function ChangeRow(oTable,nRowIndex1,nRowIndex2)
{
oTable.rows[nRowIndex1].swapNode(oTable.rows[nRowIndex2]);
}
//获取指定tag的元素 [逐级查找]
function getElement(oElement,sTag)
{
sTag = sTag.toLowerCase();
if(oElement.tagName.toLowerCase()==sTag)
return oElement;
while(oElement=oElement.offsetParent)
{
if(oElement.tagName.toLowerCase()==sTag)
return oElement;
}
return(null);
}
function ClearColor(oTable,nCurRowIndex,oCurCell)
{
//清除选中行表现
if(nCurRowIndex!=null && nCurRowIndex != -1)
{
for(i=0;i<oTable.rows[nCurRowIndex].cells.length;i++)
{
with(oTable.rows[nCurRowIndex].cells[i])
{
style.backgroundColor=oBgc;
style.color=oFc;
}
}
}
//清除可编辑表格
if(oCurCell!=null)
{
if (oCurCell.children.length>0 )
{
if(oCurCell.children[0].tagName.toLowerCase() != "img"
&&oCurCell.children[0].tagName.toLowerCase() != "a")
{
if(oCurCell.children[0].tagName.toLowerCase() == "input")
oCurCell.innerHTML=oCurCell.children[0].value.replaceHTML();
else if(oCurCell.children[0].tagName.toLowerCase() == "select")
oCurCell.innerHTML=oCurCell.children[0].options[oCurCell.children[0].selectedIndex].text;
}
}
}
}
//读取表格现有颜色
function ReadOrgColor(oTable)
{
for(var i=0;i<oTable.rows.length;i++)
{
for(var j=0;j<oTable.rows[i].cells.length;j++)
{
with(oTable.rows[i])
{
cells[j].oBgc = "";
cells[j].oFc = "";
}
}
}
}
function setEvenOddColor(mainTab)
{
//增加奇偶行的css控制 奇行:tdOdd,偶行:tdEven
for(var i=1; i<mainTab.rows.length; i++)
{
if(i%2 == 0)
mainTab.rows[i].className = "TrEven";
else
mainTab.rows[i].className = "TrOdd";
}
}
//根据在编辑框按键的不同而采取不同的动作
function judgeKeyToDo()
{
//按键是tab
if(event.keyCode == 9)
{
var cellN;
if(currentCell.cellIndex == mainTab.rows[currentRowIndex].cells.length-1)
cellN = -1;
else
cellN = currentCell.cellIndex;
var nextCell = mainTab.rows[currentRowIndex].cells[cellN+1];
//如果下一个表格未指定编辑方式,跳过
while(colStyle[parseInt(cellN+1)] == null)
{
cellN = cellN + 1;
nextCell = mainTab.rows[currentRowIndex].cells[cellN+1];
}
//如果编辑方式为txt
if(colStyle[parseInt(cellN+1)] == 'txt')
{
if(currentCell.children.length>0)
{
if(currentCell.children[0].tagName.toLowerCase() == "input")
currentCell.innerHTML=currentCell.children[0].value.replaceHTML();
else if(currentCell.children[0].tagName.toLowerCase() == "select")
currentCell.innerHTML=currentCell.children[0].options[currentCell.children[0].selectedIndex].text;
}
editCell(mainTab,nextCell,'txt',true);
}
//如果编辑方式为select
else if(colStyle[parseInt(cellN+1)] == 'sel')
{
if(currentCell.children.length>0)
{
if(currentCell.children[0].tagName.toLowerCase() == "input")
currentCell.innerHTML=currentCell.children[0].value.replaceHTML();
else if(currentCell.children[0].tagName.toLowerCase() == "select")
currentCell.innerHTML=currentCell.children[0].options[currentCell.children[0].selectedIndex].text;
}
editCell(mainTab,nextCell,'sel',true,sText[parseInt(cellN+1)],sValue[parseInt(cellN+1)]);
}
//设置当前表格为下一个单元格
currentCell = nextCell;
if(currentCell.children.length > 0)
{
if(currentCell.children[0].type == "select-one")
setTimeout('currentCell.children[0].focus()',10);
else
setTimeout('currentCell.children[0].select()',10);
}
}
//如果按键是enter
if(event.keyCode == 13)
{
if(currentCell.children[0].tagName.toLowerCase() == "input")
currentCell.innerHTML=currentCell.children[0].value.replaceHTML();
else if(currentCell.children[0].tagName.toLowerCase() == "select")
currentCell.innerHTML=currentCell.children[0].options[currentCell.children[0].selectedIndex].text;
}
}
String.prototype.replaceHTML = function()
{
var result = this;
result = result.replace(/&/g,"&");
result = result.replace(/</g,"<");
result = result.replace(/>/g,">");
result = result.replace(/\s/g," ");
if(result == "")
result = " ";
return result;
}
/*********************************** powerTableEdit.js *********************************/
</script>
<script language="javascript">
function initTable()
{
pt = new PowerTableEdit("table1");
var arrText = new Array();
arrText[0] = "数据一";
arrText[1] = "数据二";
arrText[2] = "数据三";
arrText[3] = "数据四";
var arrValue = new Array();
arrValue[0] = "1";
arrValue[1] = "2";
arrValue[2] = "3";
arrValue[3] = "4";
pt.setCol(2,'txt');
pt.setCol(3,'sel',arrText,arrValue);
pt.setCol(4,'txt');
pt.setCol(5,'txt');
pt.setCol(6,'txt');
pt.setCol(7,'txt');
}
function add()
{
var arrDa = new Array();
arrDa[0] = " ";
arrDa[1] = "九";
arrDa[2] = "Tomcat";
arrDa[3] = "数据四";
arrDa[4] = "Ellise";
arrDa[5] = "aaaa";
arrDa[6] = "2.112.521";
arrDa[7] = "美国";
pt.setCellData(arrDa);
add_row(mainTab);
}
//添加图标
function chanIcon()
{
var oImg = new Image();
oImg.src = "http://www.smallrain.net/treeimg/file.gif";
insertImg(oImg,'1');
}
function chanIcon1()
{
var oImg = new Image();
oImg.src = "http://www.smallrain.net/treeimg/collection.gif";
insertImg(oImg,'2');
}
function chanIcon2()
{
var oImg = new Image();
oImg.src = "http://www.smallrain.net/treeimg/folderopen.gif";
insertImg(oImg,'3');
}
</script></TEXTAREA> </DIV></TD></TR>
<TR>
<TD width=162 background=js_top.files/top_bg03.gif height=30> </TD>
<TD width=274 background=js_top.files/top_bg03.gif>
<DIV align=center><FONT color=#ffffff>以下代码加入<body>区域</FONT></DIV></TD>
<TD vAlign=top background=js_top.files/top_bg03.gif><INPUT class=button1 onclick="JM_cc('js_2')" type=button value=复制到我的剪贴板 name=Button2>
</TD></TR>
<TR>
<TD bgColor=#f7f7f7 colSpan=3 height=180>
<DIV align=center><TEXTAREA class=textarea1 name=js_2 rows=10 wrap=VIRTUAL cols=80><div class="divClass">
<table id=table1 border="1" cellpadding="0" cellspacing="1" bordercolor="#000000" width="100%">
<tr align=middle>
<th width=2%> </th>
<th width=13%>数字</th>
<th width=15%>名称</th>
<th width=15%>数据</th>
<th width=15%>Engine</th>
<th width=10%>字母</th>
<th width=15%>Fastest Lap</th>
<th width=15%>国家</th>
</tr>
<tr>
<td> </td>
<td>1</td>
<td>Schumacher</td>
<td data="1">数据一</td>
<td>Ferrari</td>
<td>cccc</td>
<td>1.15.872</td>
<td>德国</td>
</tr>
<tr>
<td> </td>
<td>2</td>
<td>Barrichello</td>
<td data="3">数据三</td>
<td>Ferrari</td>
<td>bbbb</td>
<td>1.16.760</td>
<td>法国</td>
</tr>
<tr >
<td> </td>
<td>3</td>
<td>Raikkonen</td>
<td data="2">数据二</td>
<td>Petronas</td>
<td>aaaa</td>
<td>1.16.875</td>
<td>缅甸 </td></tr>
<tr >
<td> </td>
<td>4</td>
<td>Heidfeld</td>
<td data="3">数据三</td>
<td>Petronas</td>
<td>aaaa</td>
<td>1.17.165</td>
<td>朝鲜</td></tr>
<tr >
<td> </td>
<td>5</td>
<td>Irvine</td>
<td data="1">数据一</td>
<td>Cosworth</td>
<td>bbbb</td>
<td>1.18.016</td>
<td>中国</td></tr>
<tr >
<td> </td>
<td>6</td>
<td>asdasdasd</td>
<td data="4">数据四</td>
<td>Cosworth</td>
<td>aaaa</td>
<td>1.18.015</td>
<td>俄罗斯</td></tr>
<tr >
<td> </td>
<td>7</td>
<td>Gengine</td>
<td data="3">数据三</td>
<td>Renault</td>
<td>cccc</td>
<td>1.15.015</td>
<td>韩国</td></tr>
<tr >
<td> </td>
<td>8</td>
<td>Slap</td>
<td data="2">数据二</td>
<td>Renault</td>
<td>bbbb</td>
<td>1.15.012</td>
<td>日本</td>
</tr>
</table>
</div>
<p>
<div style="background-color:#cccccc">
<input onclick=add() type=button value=添加一行>
<input onclick="del_row(mainTab);" type=button value=删除一行>
<input id=moveUp onclick=Move_up(mainTab) type=button value=上移一行>
<input id=moveDown onclick=Move_down(mainTab) type=button value=下移一行>
<input onclick=res_tab(mainTab) type=button value=重置表格>
<span style="font-size:12px">按tab键可以自动跳入下一个编辑单元格,enter结束编辑</span>
</div><br>
<div style="background-color:#cccccc">
<input type=button value='设置文件图标' onclick="chanIcon()"/>
<input type=button value='设置图片图标' onclick="chanIcon1()"/>
<input type=button value='设置文件夹图标' onclick="chanIcon2()"/>
</div><br>
<div style="background-color:#cccccc">
<input id=colNum size=2> <input type=button value='取列数据' onclick="alert(getColData(document.all.colNum.value))"/>
<input id=rowNum size=2> <input type=button value='取行数据' onclick="alert(getRowData(document.all.rowNum.value))"/>
</div></TEXTAREA> </DIV></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=600 align=center bgColor=#ffffff
border=0>
<TBODY>
<TR>
<TD width=162 background=js_top.files/top_bg03.gif
height=30> </TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=600 align=center border=0>
<TBODY>
<TR>
<TD style="LINE-HEIGHT: 150%" bgColor=#f7f7f7 height=45>
<DIV align=center><FONT face=Tahoma dlg? shell ?ms ,>Copyright @2000 -
2005 <A href="http://www.smallrain.net/"><STRONG>SmallRain.<FONT
color=#990000>Net</FONT></STRONG></A> , All Rights Reserved.
</FONT><BR>小雨在线 版权所有 </DIV></TD></TR></TBODY></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -