Use a collection into batch operation database in ASP

xiaoxiao2021-03-05  20

First, HTML collection attribute first, let us be familiar with the collection attribute of HTML. In form (form) data or query (query) parameter, these parameter values ​​will constitute a collection when submitted multiple parameters, and these parameter values ​​or number of parameters of the same name may be obtained at the ASP page. As in the page below (SET.HTM), 6 checkboxes use the same parameter name MyCheckbox, which is 1, 2, 3, 4, 5, 6, respectively. Collection Properties Application </ Title> </ head> <body> <p> Please select the item you want to operate, will display the data, will display Your selected item. <form method = "post" action = "set.asp"> <br> 1, <input type = "checkbox" name = "mycheckbox" value = "1"> <br> 2, <input type = "checkbox" Name = "mycheckbox" value = "2"> <br> 3, <input type = "checkbox" name = "mycheckbox" value = "3"> <br> 4, <input type = "checkbox" name = "MyCheckbox "Value =" 4 "> <br> 5, <input type =" checkbox "name =" mycheckbox "value =" 5 "> <br> 6, <input type =" checkbox "name =" mycheckbox "value =" 6 "> <br> <input type =" submit "value =" Submit Data "Name =" B1 "> </ form> </ body> </ html> When the client selects the item to display, the following ASP page (set.asp) gives the number of items and its values ​​for the client selection.</p> <p><! - set.asp -> <% @Language = vbscript%> <html> <head> <title> Collection Operation test </ title> </ head> <body> <% response.write "<br> You have chosen "& Request (" MyCheckBox "). Count &" item, "response.write" <br> You selected items: "& Request (" MyCheckbox ")%> </ body> </ html> After selecting the second, third, five and submitted the data, you will see the following results: You have chosen 3 items, your choice items are: 2, 3, 5 should notice, "2, 3, 5 "The form of the form is consistent with the form of SQL statement, we can use this form directly or indirectly, such as" SELECT * from ATABLE WHERE AFILED "" " SQL query statement is "SELECT * ATABLE WHERE AFILED IN (2, 3, 5)". Second, the application of HTML's collection attributes. We combine a practical example to discuss how to use HTML's collection properties to batch operations databases in the ASP page. Now we have an Access Database Email that records the customer email address, with a data sheet emailist, including Customerid, CustomerName, Customeremail, which represents the customer number, customer name, customer email. In the ASP page SelectId.asp, we use Checkbox to list all customers' customer names (the values ​​of each checkbox values ​​for the customer number), allowing users to send emails. When the user selects the customer and submits the data, Sendmail.asp will retrieve the electronic mailbox of these customers and send emails to these customers. Please refer to the ASP program code and comment information below.</p> <p><! - selectid.asp: List all customers 'client names -> <html> <head> <title> All customers' customer name </ title> </ head> <body> <p align = center> < Font Style = "Font-Family: Song; Font-Size: 9pt"> Please select which customers send "New Year greetings" email <form method = "post" action = "sendmail.asp"> "sendmail.asp"> "Establishment Connection to Access Database Set dbconnection = Server.createObject ("AdoDb.Connection" DBConnection.open "Driver = {Microsoft Access Driver (* .mdb)};" & _ "DBQ = C: / INETPUB / WWROOT / TEST / EMAIL .mdb "" Get all customers' customer numbers, customer name set RSCUSTOMERS = Server.createObject ("adoDb.recordset") rscustomers.open "Select Customerid, Customername, CustomeleMail from Emaillist", _ DBConnection, 1, 3, 1 "Show all Customer Name While Not RsCustomers.eof%> <br> <input type = "CheckBox" name = "Customerid" Value = "<% = rscustomers (" Customerid ")%>"> <a href = "mailto: < % = rsCustomers ( "CustomerEmail")%> "> <% = rsCustomers (" CustomerName ")%> </a> <% rsCustomers.MoveNextwendrsCustomers.closeset rsCustomers = nothingdbConnection.closeset dbConnection = nothing%> <br> <input type = "Submit" Value = "Send Email" Name = "B1" Style = "Font-Family: Song; Font-Size: 9pt"> </ form> </ body> </ html> <! Sendma Il.asp: Ges to the selected customer-generated generator message-> <html> <head> <title> to the selected customer power generation unit </ title> </ head> <body> <p align = center> <font style = "Font-Family: Song; Font-Size: 9pt"> Sending an email <% 'to establish an email <%' to the Access Database to set dbconnection = server.createObject ("AdoDb.Connection" DBConnection.open</p> <p>Driver = {Microsoft Access Driver (* .mdb)}; "& _" DBQ = C: /ineTPub/wwroot/test/email.mdb "Gets E-mail SET RSCUSTOMERS = Server.cReateObject (" AdoDb.Recordset) ") rsCustomers.Open" Select CustomerName, CustomerEmail From emailList where CustomerId in ( "& _Request (" CustomerId ") &") ", dbConnection, 1,3,1while not rsCustomers.eof 'to a customer email Set myMail = CreateObject ("Cdonts.newmail") mymail.from = "sales@test.com" MyMail.Value ("reply-to") = "sales@test.com" mymail.to = rscustomers ("Customeremail") mymail.subject = "New Year greetings from Wang Hajun" mymail.bodyformat = 1mymail.mailformat = 1 mymail.body = "Wang Haolu" & RSCustomers ("Customername") & "Say!" "MyMail.send set mymail = not%> <br> <A href="mailto:% =rscustomers (" CustomerName "%> </A>)%> </A> Email success! <% Rscustomers.MovenextWendrscustomers.closeset rcusTomers = NothingDbconnection.closset dbconnection = Nothing%> <br> Send email in the selected customer! </ Body> </ html> The above program is in WinNT4.0 IIS4 .0 ASP2.0 Access97 debug through (author: Wang Fajun wangfajun@163.net</p> <p>http://wangfajun.163.net</p> <p>)</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-38683.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="38683" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.033</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'nPZkEBNpS1o8ozE5hYVCwFIvby5odw7uUoNI1VAbbFN9KTs7TETdGqtRbnajPW0YSOSFR6sY_2B7UWXTBfy8dHXg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>