七郎's JavaBlog
草木竹石皆可為劒。至人之用人若鏡,不將不迎,應(yīng)而不藏,故能勝物而不傷。
posts - 60, comments - 14, trackbacks - 0, articles - 0
導(dǎo)航
BlogJava
首頁
新隨筆
管理
隨筆分類
ajax
Ejb(2)
ext
java
oracle
PM
QA
Thought(1)
隨筆檔案
2008年11月 (2)
2008年8月 (5)
2008年7月 (9)
2008年6月 (5)
2008年5月 (1)
2008年4月 (2)
2008年3月 (1)
2007年11月 (1)
2007年8月 (2)
2007年7月 (3)
2007年6月 (1)
2007年5月 (1)
2007年4月 (25)
最新隨筆
1.?郎咸平:未來和下一代很悲慘,我都不想講了
2.?eclipse中ext的插件安裝說明
3.?JSP直連各類數(shù)據(jù)庫大全
4.?點(diǎn)擊隱藏行 div tbody
5.?JavaScript使用技巧精萃
6.?iframe自適應(yīng)高度
7.?IE自帶的網(wǎng)頁過渡特效
8.?0x00000....藍(lán)屏
9.?etElementByID getElementsByName getElementsByTagName的區(qū)別和總結(jié)
10.?JS 動態(tài)增加刪除表格
搜索
最新評論
1.?re: Hibernate+Oracle+CLOB的讀寫問題
不行啊··
--天梯圖
2.?re: Hibernate+Oracle+CLOB的讀寫問題
啟動就報(bào)類型錯誤····
--天梯圖
3.?re: GROUP BY and HAVING用法
評論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--likydba
4.?re: 關(guān)于“Internet Explorer無法打開站點(diǎn),已終止操作”
太感謝了,解決了我的問題
--yujiaao
5.?re: 關(guān)于“Internet Explorer無法打開站點(diǎn),已終止操作”
不知道如何操作?
--磊
閱讀排行榜
1.?GROUP BY and HAVING用法(9404)
2.?關(guān)于“Internet Explorer無法打開站點(diǎn),已終止操作”(5815)
3.?SQL語句里將字符串轉(zhuǎn)換數(shù)字類型(5618)
4.?ORACLE數(shù)據(jù)庫分頁查詢/翻頁 最佳實(shí)踐(3750)
5.?hibernate中clob處理 (1930)
評論排行榜
1.?關(guān)于“Internet Explorer無法打開站點(diǎn),已終止操作”(10)
2.?Hibernate+Oracle+CLOB的讀寫問題 (2)
3.?GROUP BY and HAVING用法(1)
4.? JSP+TOMCAT下載rar附件出現(xiàn)亂碼的解決方法~ (1)
5.?[整理]SQL語句學(xué)習(xí)手冊實(shí)例版 (0)
JS 動態(tài)增加刪除表格
Posted on 2008-07-17 15:15
七郎歸來
閱讀(1766)
評論(0)
編輯
收藏
<
HTML
>
<
HEAD
>
<
script
language
="javascript"
>
//
--------------------------刪除行開始--------------------------------------
function
DeleteRow(obj)
{
//
刪除行
//
index插入的位置
alert(
"
Table1的行數(shù):
"
+
obj.rows.length
+
"
\n
"
+
"
Table1的列數(shù):
"
+
obj.rows(
0
).cells.length);
if
(obj.rows.length
>
1
)
{
obj.deleteRow(obj.rows.length
-
1
);
}
}
//
--------------------------刪除行結(jié)束--------------------------------------
//
--------------------------插入行開始--------------------------------------
function
InsertRow(obj)
{
//
插入行
//
index插入的位置
alert(
"
Table1的行數(shù):
"
+
obj.rows.length
+
"
\n
"
+
"
Table1的列數(shù):
"
+
obj.rows(
0
).cells.length);
var
oTr
=
obj.insertRow(obj.rows.length);
oTr.style.height
=
21
var
oTd
for
(j
=
0
;j
<
obj.rows(
0
).cells.length;j
++
)
{
oTd
=
oTr.insertCell(j)
oTd.innerText
=
"
"
//
" "
}
}
//
--------------------------插入行結(jié)束--------------------------------------
//
--------------------------插入列開始--------------------------------------
function
InsertCol(obj)
{
var
oTd
for
(j
=
0
;j
<
obj.rows.length;j
++
)
{
oTd
=
obj.rows(j).insertCell(obj.rows(j).cells.length);
oTd.innerText
=
"
"
//
" "
}
}
//
--------------------------插入列結(jié)束--------------------------------------
//
--------------------------刪除列開始--------------------------------------
function
DeleteCol(obj)
{
alert(Table1.rows(
0
).cells.length);
for
(j
=
0
;j
<
Table1.rows.length;j
++
)
{
if
(Table1.rows(j).cells.length
>
1
)
{
Table1.rows(j).deleteCell(Table1.rows(j).cells.length
-
1
);
}
}
}
//
--------------------------刪除列結(jié)束--------------------------------------
//
--------------------------更改表格文字開始--------------------------------------
function
showinput()
{
elm
=
event.srcElement;
if
(elm.tagName
!=
"
TD
"
)
return
;
elm.innerHTML
=
"
<input onblur='hide()' value='
"
+
elm.innerText
+
"
' style='text-align:center;width:100%;border-width: 0px;' name='input1' id='input1'></input>
"
;
document.all.item(
"
input1
"
).focus();
document.all.item(
"
input1
"
).select();
}
function
hide()
{
elm
=
event.srcElement;
elm.parentNode.innerHTML
=
elm.value
}
//
--------------------------更改表格文字結(jié)束--------------------------------------
//
function document.onmousedown(){
//
alert(event.keyCode);
//
}
</
script
>
<
TITLE
>
Lion互動網(wǎng)絡(luò)=》動態(tài)添加修改表格(行、列、內(nèi)容)
</
TITLE
>
</
HEAD
>
<
BODY
>
<
INPUT
onclick
="DeleteRow(Table1)"
type
="button"
value
="刪除行"
ID
="Button1"
NAME
="Button1"
>
<
INPUT
onclick
="InsertRow(Table1)"
type
="button"
value
="插入行"
ID
="Button2"
NAME
="Button2"
><
BR
>
<
INPUT
onclick
="DeleteCol(Table1)"
type
="button"
value
="刪除列"
ID
="Button3"
NAME
="Button3"
>
<
INPUT
onclick
="InsertCol(Table1)"
type
="button"
value
="插入列"
ID
="Button4"
NAME
="Button4"
></
P
>
<
P
><
asp:datagrid
id
="ID_Grid"
onclick
="showinput()"
runat
="server"
Width
="100%"
AutoGenerateColumns
="False"
></
asp:datagrid
>
Table1:
<
TABLE
id
="Table1"
onclick
="showinput()"
cellSpacing
="1"
cellPadding
="1"
width
="300"
border
="1"
>
<
TR
>
<
TD
>
d
</
TD
>
<
TD
>
c
</
TD
>
<
TD
>
a
</
TD
>
</
TR
>
<
TR
>
<
TD
>
a
</
TD
>
<
TD
>
b
</
TD
>
<
TD
>
c
</
TD
>
</
TR
>
</
TABLE
>
</
BODY
>
</
HTML
>
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Powered by:
BlogJava
Copyright © 七郎歸來
主站蜘蛛池模板:
上思县
|
遂溪县
|
雷州市
|
竹北市
|
呼和浩特市
|
陆良县
|
津南区
|
安顺市
|
珲春市
|
鹿邑县
|
阜宁县
|
阿坝
|
丹寨县
|
海门市
|
布拖县
|
饶河县
|
临猗县
|
开平市
|
承德县
|
甘德县
|
乐陵市
|
花莲市
|
钦州市
|
个旧市
|
宝应县
|
横峰县
|
江达县
|
两当县
|
伊金霍洛旗
|
肇州县
|
繁昌县
|
江都市
|
潜山县
|
德惠市
|
张家港市
|
扎赉特旗
|
彰化县
|
富平县
|
桂林市
|
台前县
|
上饶县
|