首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

按一下按钮增加一行,该如何处理

2012-02-06 
按一下按钮增加一行有个按钮 增加“,一按下就会在table多一行trtd 工号 /tdtdwidth 172 input

按一下按钮增加一行
有个按钮 "增加“,一按下就会在table多一行
<tr>
<td> 工号 </td>
<td   width= "172 "> <input   name= "idno "   type= "text "   id= "idno "> </td>
<td   width= "51 "> 姓名 </td>
<td   width= "196 "> <input   name= "name "   type= "text "   id= "name "> </td>
<td   width= "52 "> 部门 </td>
<td   width= "235 "> <input   name= "deptnm "   type= "text "   id= "deptnm ">   <input   name= 'Submit6 '   type= 'button '   class= 'button-style '   value= '搜索 '   onClick= 'SelectPerson(); '   style= 'cursor:hand; '> </td>
</tr>
有另一个按钮“删除”,一按下
上面一行就没了


[解决办法]
zengjiaye.asp:

<html>
<head>
<title> </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<style type= "text/css ">
<!--
.font105 { font-size:10.5pt}
.engfontv9 { font-family: Verdana; font-size: 9pt}
.engfontv105 { font-family: Verdana; font-size: 10.5pt}
form {font-size: 9pt}
input {font-size: 9pt}
select {font-size: 9pt}
textarea {font-size: 9pt}
body { font-size: 9pt}
form.engv {font-family: Verdana; font-size:9pt}
input.engv {font-family: Verdana; font-size:9pt}
select.engv {font-family: Verdana; font-size:9pt}
textarea.engv {font-family: Verdana; font-size:9pt}
input.noborder {margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;height: 13px;border-width: 0px 0px 0px 0px;text-align:center}
body { font-size: 9pt}
td { font-size: 9pt}
a:link {color: #004080; text-decoration: none}
a:visited {color: #004080; text-decoration: none}
a:hover { color: #BE2143; text-decoration: underline}
a.9pt:link {font-size: 9pt; color: #004080; text-decoration: none}
a.9pt:visited { font-size: 9pt; color: #004080; text-decoration: none}
a.9pt:hover { font-size: 9pt; color: #BE2143; text-decoration: underline}
-->
</style>
<script language=javascript>
function tick()
{
theform.plswait.value=theform.plswait.value+ '. ';
window.setTimeout( "tick() ",1000);
}
allCount=0;


function addline()
{
newRow=datatable.insertRow(datatable.rows.length);
newRow.ln=allCount;
newRow.id= "line "+allCount;
c0=newRow.insertCell(0);
c0.bgColor= "#FFFFFF ";
c0.innerHTML= " <input size=10 class=noborder name=sCatalog> ";
c1=newRow.insertCell(1);
c1.bgColor= "#FFFFFF ";
c1.innerHTML= " <input size=12 class=noborder name=sClass> ";
c2=newRow.insertCell(2);
c2.bgColor= "#FFFFFF ";
c2.innerHTML= " <input size=8 class=noborder name=sMaterial> ";
c3=newRow.insertCell(3);
c3.bgColor= "#FFFFFF ";
c3.align= "CENTER ";
c3.innerHTML= " <input type=button class=noborder value=插入 style= 'cursor:hand;background-color:#FFFFFF ' onmouseover=this.style.color= '#C0C0C0 ' onmouseout=this.style.color= '#000000 ' onclick=insertline(line "+allCount+ ")> ";
c4=newRow.insertCell(4);
c4.bgColor= "#FFFFFF ";
c4.align= "CENTER ";


c4.innerHTML= " <input type=button class=noborder value=删除 style= 'cursor:hand;background-color:#FFFFFF ' onmouseover=this.style.color= '#C0C0C0 ' onmouseout=this.style.color= '#000000 ' onclick=delline(line "+allCount+ ")> ";
allCount++;
}

function insertline(lineid)
{
for(i=0;i <datatable.rows.length;i++)
{
if(datatable.rows[i].id==lineid.id)
{
newRow=datatable.insertRow(i);
newRow.ln=allCount;
newRow.id= "line "+allCount;
c0=newRow.insertCell(0);
c0.bgColor= "#FFFFFF ";
c0.innerHTML= " <input size=10 class=noborder name=sCatalog> ";
c1=newRow.insertCell(1);
c1.bgColor= "#FFFFFF ";
c1.innerHTML= " <input size=12 class=noborder name=sClass> ";
c2=newRow.insertCell(2);
c2.bgColor= "#FFFFFF ";
c2.innerHTML= " <input size=8 class=noborder name=sMaterial> ";
c3=newRow.insertCell(3);
c3.bgColor= "#FFFFFF ";
c3.align= "CENTER ";
c3.innerHTML= " <input type=button class=noborder value=插入 style= 'cursor:hand;background-color:#FFFFFF ' onmouseover=this.style.color= '#C0C0C0 ' onmouseout=this.style.color= '#000000 ' onclick=insertline(line "+allCount+ ")> ";
c4=newRow.insertCell(4);
c4.bgColor= "#FFFFFF ";
c4.align= "CENTER ";
c4.innerHTML= " <input type=button class=noborder value=删除 style= 'cursor:hand;background-color:#FFFFFF ' onmouseover=this.style.color= '#C0C0C0 ' onmouseout=this.style.color= '#000000 ' onclick=delline(line "+allCount+ ")> ";
allCount++;
return;
}
}
}


function delline(lineid)
{
for(i=0;i <datatable.rows.length;i++)
{
if(datatable.rows[i].id==lineid.id)
{
datatable.deleteRow(i);
return;
}
}
}


var a=document.getElementsByTagName( "input ")
for(var i=0;i <a.length;i++)
{
if(a[i].type== "text ")
{
if(a[i].name.substr(0,7)== "sCatalog ")
{
a[i].value
}
}
}

var a=document.getElementsByTagName( "input ")
for(var i=0;i <a.length;i++)
{
if(a[i].type== "text ")
{
if(a[i].name.substr(0,7)== "sClass ")
{
a[i].value
}
}
}

var a=document.getElementsByTagName( "input ")
for(var i=0;i <a.length;i++)
{
if(a[i].type== "text ")
{
if(a[i].name.substr(0,7)== "sMaterial ")
{
a[i].value
}
}
}

</script>
</head>
<body bgcolor=#FFFFFF leftmargin=2 topmargin=5>

<table width=950 cellpadding=0 cellspacing=0 align=center>
<form name= "theform " method= "post " action= "deshuju1.asp ">
<tr>
<td> &nbsp;
</td>
</tr>
</table>

<table width=950 cellpadding=0 cellspacing=0 bgcolor=#C0C0C0 align=center>
<tr>
<td>
<table width=950 cellspacing=1 cellpadding=0 id=datatable>
<tr align=center height=17 id=titlerow>
<td bgcolor=#FFFFFF> <b> 公司名称 </b> </td>
<td bgcolor=#FFFFFF> <b> 公司简称 </b> </td>
<td bgcolor=#FFFFFF> <b> 品种 </b> </td>


<td bgcolor=#FFFFFF> <b> 插入 </b> </td>
<td bgcolor=#FFFFFF> <b> 删除 </b> </td>
</tr>
</table>
<table>
<tr> <td> <input type=button value=增加一行 onclick=addline()> </td> </tr>
</table>
</td>
</tr>
</table>
<table cellspacing=1 width=950 align=center>
<tr height=5> <td> </td> </tr>
<tr>
<td>
<input type= "hidden " id= "sCatalog " name= "sCatalog ">
<input type= "hidden " id= "sClass " name= "sClass ">
<input type= "hidden " id= "sMaterial " name= "sMaterial ">

<input type=submit name=bok style= "font-weight:bold " value=确认提交> <br>
<input type=reset style= "font-weight:bold " value=重新填写>
</td>
</tr>

</table>
<table width=950 cellpadding=0 cellspacing=0 align=center>
<tr>
<td> &nbsp;
</td>
</tr>
</form>
</table>
</body>
</html>

deshuju1.asp:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN "
"http://www.w3.org/TR/html4/loose.dtd ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 无标题文档 </title>
<style type= "text/css ">
<!--
.STYLE1 {color: #000000}
-->
</style>
</head>
<body>
<%
sCatalog=split(request( "sCatalog "), ", ")
sClass=split(request( "sClass "), ", ")
sMaterial=split(request( "sMaterial "), ", ")

set rsbc=server.createobject( "adodb.recordset ")
sqlbc= "select * from xxx "
rsbc.open sqlbc,conn,1,3

for i=0 to ubound(sCatalog)-1
rsbc.addnew
rsbc( "gsmc ")=trim(sCatalog(i))
rsbc( "xhgsjc ")=trim(sClass(i))
rsbc( "xhpz ")=trim(sMaterial(i))

rsbc.update
next
rsbc.close
Response.Write " <Script Language=JavaScript> alert( '发布成功! ');location.href= 'zengjiaye.asp '; </Script> "

%>
</body>
</html>

热点排行