下面的代码是可以正常写入数据库的,但是实际应用中添加的行数是不定的,所以需要设置,
1.点击(添加)就会添加一行,点击(删除)就会删除当前行
2.把数据写入数据库,(因为代码中是可以写入一行数据的,但是如果实现了添加一行,那么就会有2行相同的name,这个我不知道怎么做,希望有高手可以在我源码上修改下,最终使用给满分,谢谢。)
<body>
<table width="650" border="1">
  
  <tr>
    <td>
<input type="text" name="chanpming" ></td>

    <td>
<input type="text" name="caixinghao" ></td>
    <td>添加一行 删除当前行</td>
  </tr>
  <tr>
    <td>录入人:</td>
    <td>
<input type="text" name="caixinghao" ></td> 
  </tr>
  <tr>
    <td height="30"> </td>
     <td class="category" colspan="2" align="center">
        <input name="submit" type="submit" onClick="return check()" value=" 确 认 " class="button">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input name="reset" type="reset" value=" 重新填写 " class="button">
        <input type="hidden" name="hid1" value="ok"></td></table>
<%
else
nowchanpming=request("chanpming")
nowcaixinghao=request("caixinghao")
nowshouhuoren=request("shouhuoren")
sql="select * from caigou where caixinghao='"&nowcaixinghao&"'"
set rs=conn.execute(sql)
if rs.eof=false then
%>
<script language="javascript">
alert("您输入的型号已经存在!")
window.history.go(-1)
</script>  
<%
  response.end
end if
set rs=server.createobject("ADODB.RecordSet")
sql="select * from caigou where 1=2"
rs.open sql,conn,1,3
rs.addnew
rs("chanpming")=nowchanpming
rs("caixinghao")=nowcaixinghao
rs("shouhuoren")=nowshouhuoren
rs.update
%>
<script language="javascript">
alert("添加成功!")
window.location.href="caigou.asp"
</script>  
<%
end if
%>
</body>