欢迎光临
我们一直在努力

自定义每次添加的记录数,包含客户端的数据检查(绝对100%原创)

建站超值云服务器,限时71元/月

  当我们有时在添加新记录时,一次添加一条的操作很不方便,尤其是在录入大批量的数据时,比如:学生成绩。
   下面是我给一个客户做的自定义添加记录数(即:用户可以自己选择当前一次添加多少条记录),并用vb函数对每个需要输入的文本框做了检查。

下面是源程序:

<%@ language=vbscript %>
<%
文件名:dd_product_price.asp
功能:添加商品价格详细资料
说明:后台程序
程序:小白
时间:2002-5-15
更新:
更新说明:
公司:坐标公司
主页:www.zbhn.com
%>

<html>
    
<head>
<title> <%=application("web_name")%> —>添加商品价格资料</title>
<meta name="generator" content="microsoft frontpage 4.0">
<style type="text/css"> <!– a:link {color:darkslateblue;text-decoration:none}
    a:visited {color:darkslateblue;text-decoration:无}
    a:hover {color:brown;text-decoration:底线}
    input.radio {background: navyblue; color:#000000}
    font { font-size: 9pt; line-height: 13pt; font-family:ms shell dlg,tahoma}
    td { font-size: 9pt; line-height: 13pt; font-family:ms shell dlg,tahoma}
    textarea { background-color: #e8e8e8; border-bottom: 1px double; border-left: 1px double; border-right: 1px double; border-top: 1px double; color: #000000;; font-size: 9pt ;font-family:ms shell dlg,tahoma}
    input { background-color: #e8e8e8; border-bottom: 1px double; border-left: 1px double; border-right: 1px double; border-top: 1px double; color: #000000;; font-size: 9pt; font-family:"ms shell dlg", "tahoma"; background-position: center}
    –></style>
<script language="javascript" src="js/refuse_visit.js"></script>
<script language="javascript" src="js/max_window.js"></script>
</head>
    <body>
        <!–#include file="sjkpzwj/ytxx_conn.inc"–>
        <p align="center">
            <%
            dim url
            url=request.servervariables("script_name")
    on error resume next
    record=request.querystring("record")
    if record="" then
    record=1
    end if
    record=cint(record)
    if err.number <> 0  then
    record=1
    response.write "操作不当,请下次小心点"
    end if
if request.servervariables ("request_method")="post" then                    
如果提交过来的是post方法,则添加记录到数据库

dim text1(20),text2(20),text3(20),text4(20)

______________________
sub gave_value(text,xx)
on error resume next
count=0
for each item in request.form(text)
xx(count)=item
count=count+1
next
if err.number <> 0 then

response.write "sub err:"& err.description
end if
end sub
on error resume next
____________________
call gave_value("text1",text1)
call gave_value("text2",text2)
call gave_value("text3",text3)
call gave_value("text4",text4)
if err.number <> 0 then
response.write "call sub err:"&err.description
end if

%%%%%%%%%%%%%%%%%%%%%%%%
on error resume next

if err.number <> 0 then
response.write "show text1 err:"&err.description
response.end  
end if
%%%%%%%%%%%%%%%%%%

%>
<center>添加商品价格资料 </center>
     
    <%
    set rs=server.createobject ("adodb.recordset")
             
            on error resume next
             
            rs.open "select * from price  where 1=2",str_connection,1,3  
             
            ************************************
            if err.number <> 0 then
                 response.write "error—><br>"&err.description &"<br><font color=red>;please contact  with  the <font color=red> web master</font>!</font>"
                 rs.close  
                set rs=nothing
                response.end  
                 
            end if
            **************************************
            连接数据库、打开数据表成功后
            ______使用addnew方法添加记录________
             
            on error resume next
            for jj=0 to record-1
            rs.addnew
                rs(1)=text1(jj)  
                rs(2)=text2(jj)
                rs(3)=text3(jj)
                rs(4)=text4(jj)
            rs.update  
            next
            rs.close  
            set rs=nothing
         
            if err.number <> 0 then
            如果提交失败
                response.write "error—><br>"&err.description &"<br><font color=red>;please contact our administrators!</font>"
                        response.end              
            end if
             
            ______________________________________
            dim pass
            pass=true
            if pass=true then
            %>
            <script language=javascript>
<!–
window.alert ("提交成功,请返回")
if(window.opener !=null){
window.opener.location.reload()
}
self.location ="<%=url%>?record=<%=record%>"
//–>
</script>

             
             
            <%
            end if
            response.end  
   
    
end if    end of // if ….="post" then         

%>
            <font size="3" color="#ff0000"><b>添加<font color="#ff8844" size="9">→产品价目←</font>的资料</b></font>   
            <form name=form1 id="form1">
                     
             
  <table style="border-collapse: collapse" cellspacing="1" cellpadding="1" width="100%" border="0" id="table1">
    <tbody>  
    <tr bgcolor="#9a007b">  
      <td class="unnamed1" width="14%" height="22">  
        <div align="center"><font color="#ffffff">产品名称</font></div>
      </td>
  
      <td class="unnamed1" width="14%" height="22">
        <div align="center"><font color="#ffffff">单位</font></div>
      </td>
      <td class="unnamed1" width="14%" height="22">
        <div align="center"><font color="#ffffff">出厂价(元)</font></div>
      </td>
      <td class="unnamed1" width="14%" height="22">
        <div align="center"><font color="#ffffff">包装形式</font></div>
      </td>
      </tr>
    <% for i=0 to record-1%>
    <tr bgcolor="#fdd2f4">
      <td class="unnamed1" width="14%"  height="22">
        <div align="center">
          <input type="text"   tabindex=<%=i * record +1%> name="text1" size="20" id="text1">
        </div>
      </td>
      <td class="unnamed1" width="14%" height="22">
        <div align="center">
          <input type="text" tabindex=<%=i * record + 2%> name="text2" size="20" id="text2">
        </div>
      </td>
      <td class="unnamed1" width="14%" height="22">
        <div align="center">
          <input type="text"   tabindex=<%=i * record + 3%> name="text3" size="20" id="text3">
        </div>
      </td>
      <td   class="unnamed1" width="14%" height="22"   >
        <div align="center">
          <input tabindex=<%=i * record + 4%>  type="text" name="text4" size="20" id="text4">
        </div>
      </td>
   
    </tr>
    <%next%>
    <tr bgcolor="#fdd2f4">
      <td class="unnamed1" width="100%" height="22" colspan="4">请选择:一次添加  
        <select id="select1" name="select1" size="1"   
onchange="javascript:self.location=this.options[this.selectedindex].value"                        >
          <option selected value="<%=url%>?record=1">1</option>
          <option  value="<%=url%>?record=1">1</option>
          <option value="<%=url%>?record=2">2</option>
          <option  value="<%=url%>?record=3">3</option>
          <option value="<%=url%>?record=4">4</option>
          <option  value="<%=url%>?record=5">5</option>
          <option  value="<%=url%>?record=6">6</option>
          <option  value="<%=url%>?record=7">7</option>
          <option  value="<%=url%>?record=8">8</option>
          <option  value="<%=url%>?record=9">9</option>
          <option  value="<%=url%>?record=10">10</option>
          <option  value="<%=url%>?record=15">15</option>
          <option  value="<%=url%>?record=20">20</option>
        </select>
          条记录                                 
        <input id="submit1" type="button" onclick="notcheck()" value="提交" name="submit1">
             
        <input type="reset" value="reset" id="reset1" name="reset1">
            当前操作:添加<font color=red><%=record%></font>条记录 </td>
    </tr>
    </tbody>
  </table>
                </form>
                
<script  language=vbscript >

<!–
此段代码由小白源创
如有转载,请勿删除此行代码,谢谢
对于只熟悉js的朋友
做相应的代码转换,就可以转换为js函数
我在这里就略过了
email:xiaobai@17560.net
********************************************

function notcheck()  1
dim pass
pass=true
on error resume next  2

for k=0 to  document.all.length-1

if  ucase(document.all (k).tagname) ="input" then  444  
  判断是否为input元素
  set  input1=document.all (k)
  if ucase(input1.type) = "text" then  如果是可输入的文本框
if  input1.value=""  then  6
  msgbox "请在光标处输入资料"
  input1.focus()
  pass=false
  exit for
end if  /66
  end if

end if  /444

next

if err.number > 0  then
pass=false
  表示异常发生
  alert("异常发生")
end if
if pass=true then
form1.action="<%=url%>?record=<%=record%>"
form1.method="post"
form1.submit()
end if
end function  11111

//–>

</script>

    </body>
</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 自定义每次添加的记录数,包含客户端的数据检查(绝对100%原创)
分享到: 更多 (0)