我做的是一个物流系统,出站的货物信息提交数据后。以列表的形式显示出来。在每条后面加一个复选框,货物到站后点击复选框选中,点确定提交到数据库(类似于电子邮件的选中邮件删除的形式)。但我再给每个复选框命名的时候不知道该怎么办了,请大家指教(最好是给出类似的程序让我参考一下),小弟不胜感激!
[此贴子已经被作者于2005-9-6 23:07:08编辑过]
[此贴子已经被作者于2005-9-6 23:07:08编辑过]
我做的那个例子,短信是以编号来唯一区别的。用编号来区别,好吧那我就把这页的ASP源码发过来 以下为ASP源码。 [CODE] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>用户短信列表</title> <!--#include file="CONDB.inc"--> <!--引用数据库连接文件--> <% On Error Resume Next '声明数据库记录集对象 Dim rsUsMsg Dim MsgBhStr '创建数据库记录集对象 Set rsUsMsg=Server.CreateObject("ADODB.Recordset") '设定数据库记录集游标类型 rsUsMsg.cursortype=3 '打开记录集对象 rsUsMsg.Open "select * From UserMsg where UserName='"&Session("UserName")&"' ORDER BY MsgID DESC",con 'Session("Username")=Request("UsName") '设定每页显示记录数 rsUsMsg.pagesize=6 '得到请求的页号 IF request("page")<>"" then page=clng(request("page")) Else page=1 End IF IF page<1 Then page=1 If page>rsUsMsg.pagecount Then page=rsano.pagecount rsUsMsg.absolutepage=page '网页样式初始化代码 Dim PageStyleT Set PageStyleT=New PageStyle Call QueryStyle("用户短信列表",PageStyleT) %> <script language="JavaScript"> function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); function gotopage(quname) { page=document.fm.selpage.value self.location="UserMsgGet.asp?UsName="+quname+"&page="+page } function ChkSel() { var BhStr var ConStr; BhStr=""; ConStr=""; for(var j=0;j<document.Control.ControlGroup.length;j++) { if(document.Control.ControlGroup[j].checked) { ConStr=document.Control.ControlGroup[j].value; } } if(ConStr!="DelPageMsG") { if(ConStr!="DelAllMsg") { for(var i=0;i<document.msg.length;i++) { if(document.msg[i].checkbox.checked) { BhStr=BhStr+document.msg[i].checkbox.value+"," } } if(BhStr=="") { alert("请选择要删除的短信"); return false; } document.Control.MsgNumStr.value=BhStr; document.Control.Cont.Value=ConStr; document.Control.MsgNumStr.text=BhStr; document.Control.Cont.text=ConStr; Control.action="UserMsgControl.asp"; Control.submit(); } } else { Control.action="UserMsgControl.asp"; Control.submit(); } //BhStr=""; //ConStr=""; //alert(document.Control.MsgNumStr.text); //alert(document.Control.Cont.text); Control.action="UserMsgControl.asp"; Control.submit(); } </script> <style type="text/css"> <!-- <%=PageStyle.StyleString%> --> </style> <style type="text/css"> <!-- .style1 {font-size: 12px} .style2 {font-size: 10px} A { TEXT-TRANSFORM: none; TEXT-DECORATION: none } body { background-color: <%=PageStyleT.BackGround%>; } --> </style> </head> <body> <table width="440" height="301" border="0"> <tr> <td><table width="440" border="0"> <tr> <td width="38" height="15"><div align="center"><span class="style1">编号</span></div></td> <td width="81"><div align="center" class="style1">发送者</div></td> <td width="127"><div align="center" class="style1">主题</div></td> <td width="119"><span class="style1">发送时间</span></td> <td width="53"><div align="center" class="style1">操作</div></td> </tr> <% On Error Resume Next '定义循环变量 Dim iPage Dim TempStr For iPage=1 to rsUsMsg.Pagesize Response.Write("<tr>") Response.Write("<td height=16><span class=style1>"&rsUsMsg.Fields(2).Value&"</span></td>") Response.Write("<td> <a href=UsQuery.asp?UsName="&rsUsMsg.Fields(3).Value&"&UsFName="&Request("UsName")&" target=_parent class=style2>"&rsUsMsg.Fields(3).Value&"</a> </td>") IF rsUsMsg.Fields(7).Value="F" Then IF Len(rsUsMsg.Fields(4).Value)<8 Then Response.Write("<td><span class=style1><strong><a href=UserMsgDisplay.asp?bh="&rsUsMsg.Fields(2).Value&" target=_self>"&rsUsMsg.Fields(4).Value&"</a></strong></span></td>") Else Dim i For i=0 to 8 TempStr=TempStr&Mid(rsUsMsg.Fields(4).Value,i+1,1) Next Response.Write("<td><span class=style1><strong><a href=UserMsgDisplay.asp?bh="&rsUsMsg.Fields(2).Value&" target=_self>"&TempStr&"…</a></strong></span></td>") TempStr="" End IF Else IF Len(rsUsMsg.Fields(4).Value)<8 Then Response.Write("<td><span class=style1><a href=UserMsgDisplay.asp?bh="&rsUsMsg.Fields(2).Value&" target=_self>"&rsUsMsg.Fields(4).Value&"</a></span></td>") Else Dim j For j=0 to 8 TempStr=TempStr&Mid(rsUsMsg.Fields(4).Value,j+1,1) Next Response.Write("<td><span class=style1><a href=UserMsgDisplay.asp?bh="&rsUsMsg.Fields(2).Value&" target=_self>"&TempStr&"…</a></span></td>") TempStr="" End IF End IF Response.Write("<td><span class=style1>"&rsUsMsg.Fields(6).Value&"</span></td>") Response.Write("<td><form name=msg method=post action=>") Response.Write("<div align=center>") MsgBhStr=MsgBhStr&rsUsMsg.Fields(2).Value&"|" Response.Write("<input type=checkbox name=checkbox value="&rsUsMsg.Fields(2).Value&">") Response.Write("</div>") Response.Write("</form></td>") Response.Write("</tr>") rsUsMsg.MoveNext IF rsUsMsg.EOF Then Exit For End If Next %> </table></td> </tr> </table> <table width="445" border="0"> <tr> <td width="439" height="23"><span class="style1"> 节省每一分空间,请及时删除无用信息 </span></td> </tr> <tr> <td height="23"><form name="Control" method="get" action=""> <input type="button" name="button" value="提交" onClick="ChkSel();"> <input type="radio" name="ControlGroup" value="DelSelMsG"> <label><span class="style1">删除选中短信</span></label> <input type="radio" name="ControlGroup" value="DelPageMsG"> <label><span class="style1">删除本页短信</span></label> <input type="radio" name="ControlGroup" value="DelAllMsg"> <label><span class="style1">删除所有短信</span></label> <input type="hidden" name="MsgNumStr" value="<%=MsgBhStr%>"> <input type="hidden" name="Cont" value=""> </form></td> </tr> </table> <table width="445" height="36" border="0" cellspacing="0"> <tr> <td width="127"><span class="style1">共<%=rsUsMsg.pagecount%>页 当前第<%=page%>页</span></td> <td width="166" height="32"><div align="center" class="style2"> <% On Error Resume Next IF page<>1 Then Response.Write("[<a href=UserMsgGet.asp?page="&(page-1)&"&UsName="&Request("UsName")&">上一页</a>]") Else Response.Write("[上一页]") End IF IF page<>rsUsMsg.pagecount Then Response.Write("[<a href=UserMsgGet.asp?page="&(page+1)&"&UsName="&Request("UsName")&">下一页</a>]") Else Response.Write("[下一页]") End IF %> </div></td> <td width="140"> <form name=fm method=post action=""> <div align="center"> <select name="selpage"> <% On Error Resume Next Dim p For p=1 to rsUsMsg.pagecount Response.Write("<option value="&p&">第"&p&"页</option>") Next %> </select> <input type="button" name="Submit" onClick=gotopage('<%=Request("UsName")%>') value="跳转到"> </div> </form></td> </tr> </table> <p> </p> <p> </p> </body> <% 'stop On Error Resume Next '网页对象析构区域 Set PageStyleT=Nothing rsUsMsg.Close con.Close Set rsWebArt=Nothing Set con=Nothing %> </html> [/CODE]
页面工作原理,每条短信在数据库中以编号为主键。点击后会得到如90,100,10的编号字符串。 处理页面通过函数来解析出编号数组 以下为解析函数参数str为90,100,10的字符串参数sstr为数组解析后sstr的数组元素为 sstr(0)="90" sstr(1)="100" sstr(2)="10" 利用编号处理页面来从数据库中读取编号所对应的相应短信,然后对短信进行相应处理。 Function MidStr(str,sstr())'此为解析函数源码。 Dim tstr, mstr, tui Dim i, num, j num = 0 For i = 0 To Len(str) tstr = Mid(str, i + 1, 1) If tstr = "," Then num = num + 1 End If Next ReDim sstr(num) j = 0 For i = 0 To Len(str) tstr = Mid(str, i + 1, 1) If tstr <> "," Then mstr = mstr & tstr Else If j < num Then sstr(j) = mstr mstr = "" j = j + 1 End If End If Next MidStr = num End Function 以上为该代码的执行原理。
[此贴子已经被作者于2005-9-7 9:16:18编辑过]
[此贴子已经被作者于2005-9-7 10:32:23编辑过]