动态表单域做好了,但是不能删除!!help me!!

crazyxp 2003-03-18 08:00:33
总是有错,大概是找不到删除节点!那个搞手指点一下!谢谢!

<HTML>
<HEAD>
<TITLE>Advanced Select</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
var cnt=0
function Add()
{
var temp = document.body.children.item(0).rows.item(1).cells.item(0).children.item(0).rows.item(0).cells.item(0).children.item(0).children.item(0)
temp.insertRow(temp.rows.length);
temp.rows.item(temp.rows.length -1).insertCell(0);
var xx=temp.rows.length -1 ;
var sHTML;
sHTML=""
+"<table>"
+" <tr>"
+" <td colspan='3'>("+ cnt++ +")Fild:<select name='select'>"
+" </select>"
+" <select name='select2'>"
+" <option value='=' selected>=</option>"
+" <option value='<>'><></option>"
+" <option value='like'>like</option>"
+" <option value='<='><=</option>"
+" <option value='>='>>=</option>"
+" </select>Value:<input type='text' name='textfield'>"
+" <select name='select3'>"
+" <option value'' selected>NULL</option>"
+" <option value='and'>AND</option>"
+" <option value='or'>OR</option>"
+" </select>"
+" </form>"
+" <td colspan='3'><input type='button' value='删除' onclick='Delete(this);'>"
+" </td>"
+" </tr>"
+"</table>"
temp.rows.item(temp.rows.length-1).cells.item(0).innerHTML=sHTML; temp.rows.item(temp.rows.length-1).cells.item(0).children.item(0).rows.item(4).cells.item(0).children.item(0).text=xx;
}

function Delete(x)
{
var temp=document.body.children.item(0).rows.item(1).cells.item(0).children.item(0).rows.item(0).cells.item(0).children.item(0).children.item(0)
temp.deleteRow(x.text.valueOf())
for (var j=0;j<temp.rows.length;j++) temp.rows.item(j).cells.item(0).children.item(0).rows.item(4).cells.item(0).children.item(0).text=j;
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<table style="border-collapse: collapse" width="100%">
<form name="form1" method="post" >
<tr>
<td align="center"><INPUT TYPE="button" value="添加搜索条件" onclick="Add()"></td>
</tr>
<tr>
<td align="center"> <TABLE align=center border=0 width="100%" height="100%">
<TR>
<TD width="100%" height="350">
<DIV style=" OVERFLOW: auto;BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid; WIDTH: 100%; HEIGHT: 100%">
<table>
<tr>
<td>   Fild:
<select name="select">
</select> <select name="select2">
<option value="=" selected>=</option>
<option value="<>"><></option>
<option value="like">like</option>
<option value="<="><=</option>
<option value=">=">>=</option>
</select>Value:<input type="text" name="textfield"> <select name="select3">
<option value"" selected>NULL</option>
<option value="and">AND</option>
<option value="or">OR</option>
</select>
</td>
</tr>
</table><TABLE width="100%">

</TABLE>
</DIV>
</TD>
</TR>
</TABLE>
</td>
</tr>
<tr>
<td align="center">
<INPUT TYPE="submit" value=" 提 交 ">
  
<INPUT TYPE="reset" value=" 清 空 ">
</td>
</tr>
</form>
</table>
</BODY>
</HTML>
...全文
18 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
crazyxp 2003-03-19
  • 打赏
  • 举报
回复
to wangxj0600 sorry是我搞错了!不过删除了好像也没用!
crazyxp 2003-03-19
  • 打赏
  • 举报
回复
to wangxj0600 我没有嵌套使用啊!

to misfans 使用这个删除函数,表格不增加,页面也不正常!

help me!~
misfans 2003-03-19
  • 打赏
  • 举报
回复
function Delete(x)
{
while(x.tagName != 'TR')
x = x.parentElement;
x.parentElement.removeChild(x);
event.CancelBubble = true; }

}
wangxj0600 2003-03-18
  • 打赏
  • 举报
回复
form不能嵌套使用
<form>
<form>
</form>
</form>这样使用是错误的

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧