快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

自定义每次添加的记录数,包含客户端的数据检查

当我们有时在添加新记录时,一次添加一条的操作很不方便,尤其是在录入大批量的数据时,比如:学生成绩。
下面是我给一个客户做的自定义添加记录数(即:用户可以自己选择当前一次添加多少条记录),并用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>
返回类别: 教程
上一教程: 关于水晶报表10 的字报表数据填充和显示
下一教程: ACCESS数据库的存储上限

您可以阅读与"自定义每次添加的记录数,包含客户端的数据检查"相关的教程:
· 如何存取三层式结构的数据库的记录
· 对数据库中的记录用上一条下一条显示(三)
· 关于ADODB.STREAM的写数据库数据到客户端文件的实践
· ADO如何新增修改删除数据库的记录
· 从数据表中取出第N条到第M条的记录的方式
    微笑服务 优质保证 索取样品