Survey system with ASP to make Zhang Yang personality

xiaoxiao2021-03-06  42

With the popularity of the network, online investigations often achieve better results. Place a fun problem survey board on your own personal site, there is a lot of adding color to the website; As a WebMaster, if your website needs to investigate a topic, and you hate the use of the free-off board provided by others (free is often a price, such as advertising!), Then I suggest you spend more than ten minutes. Time to read this article describes the article with the ASP production survey board. As long as you use the code COPY in the text to your machine, make a little modification, you immediately have a personalized survey board belonging to your own. Ok, let's take a spirit.

This survey board has three documents: Show survey issues (research.html), handling user selection (select.asp), browsing the findings (ViewResult.asp). The design idea is: ASP acquires information sent by the form, and modifies the recorded database, then the ASP reads the database, obtains the number of votes for each survey problem, and the number of votes is displayed. The survey results are given in an intuitive proportion. In the critical place of the program, I give more detailed comments, this no longer tells the basic knowledge of ASP. Readers can go to the Tao Bar ASP column. Of course, I hope that when you debug the program on your own server, you don't understand, or check the ASP technical manual around you, see the detailed grammar of the object, method, or function tried to modify, see how the results change - This is a good way to learn and program.

First, show investigation problems (research.html)

The design of the investigation problem is based on the actual situation, or pays attention to practical or interest, the style displayed on the web page is also simple or lively. In this example, the author's home page is about "What is the most important thing in the 21st century?" Fun survey, for illustrative problems, the following code omitted aesthetically modified code, you can use the skills of skills to beautify the survey problem when designing the table. In order to make the edition 蜾  鞑 鞑 辈 辈 跋 鼻 耙 妫 妫    说 说     鲂    鲂         :: :::::::::::::::::::::::::

Survey board test </ title> <head> <! - start: Defines a new window -> <script language = javascript> <! - var newwindow = nullfunction openwindow (htmurl) {ix (! newwindow || newwindow.closed) {newwindow = window.open (htmurl, "newwin", "toolbar = no, resiza = no, scrollbars = no, width = 400, height = 280");} else {newwindow. Focus ();}} // -> </ script> <! Defines a new window -> </ head> <body> <! - start: survey topic, option -> < p> What is the most important thing in the 21st century? </ p> <form method = "post" action = "vote / select.asp" name = "research" language = "javascript" onsubmit = "openwindow ()" target = "newwin"> <p align = "left" > <br> <input type = "radio" value = "1" name = "options"> Knowledge (knowledge is power) <br> <input type = "radio" value = "2" name = "options"> degree (Due to the educational society) <br> <input type = "radio" value = "3" name = "options"> Money (economy is the foundation) <br> <input type = "radio" value = "4" name = "Options"> Love (never enter the love of the grave) <br> <input type = "radio" value = "5" name = "options"> Ideal (Tian, ​​ideal what) <br> <input type = "Radio" value = "6" name = "options"> democratic awareness (care politics) <br> <input type = "radio" value = "7" name = "options"> scientific thinking (Science and Education) <br> <Input Type = "</p> <p>Submit "Value =" Submit "Name =" Voting "> <input type =" "value =" View "Name =" Viewing "onclick =" openwindow (vote / viewresult.asp "> </ form> <! - Start: Survey, Options -> </ body> </ html> II. Processing User Selection (select.asp) Based on the survey option above, we get the design of the database researchDb.mdb in the investigation ticket (with Access Table as an example, the name is: research. If your database and table do not have the above name, then you don't forget to change accordingly in the procedure and operation.</p> <p>Store the investigation of the table research:</p> <p>Field Name Data Type Default ID Auto Number 1 SELECT1 Digital 0 SELECT2 Digital 0 SELECT3 Digital 0 SELECT4 Digital 0 SELECT5 Digital 0 SELECT6 Number 0 SELECT7 Digital 0</p> <p>After you build the database, we will build a data source on the server. First, run "ODBC" in the Control Panel, select "System DSN", press "Add" button, select "Microsoft Access Driver", then press "Finish" button, then in ODBC Settings "Data Source Name "Input Box Enter the database name, this example is researchDB, then press the" Select "button to select the database file (you will not say that you have forgotten the data in which you just designed), then press" OK ", You can see the newly created data source researchDB. This way, we can call in the ASP.</p> <p>SELECT.ASP:</p> <p><%</p> <p>The following IF statement is by verifying whether the Selected is empty to determine if the user has selected if Request.form ("Options") <> EMPTY THEN%></p> <p><% The following IF statement is to prevent users from continuously follow the results of the survey by comparing the REQUEST's two Collection (ServerVariables and cookies). If NOT REQUEST.SERVARIABLES ("Remote_Addr") = Request.Cookies ("ipaddress" Then writes the IP information of the access customer to cookiesResponse.cookies ("ipaddress") = request.serverVariables ("remote_addr")%> <% Connection object, open database SET CONN = Server.createObject ("AdoDb.Connection") Conn.open "ResearchDB"%></p> <p><% Define Variable DIM RSDIM SQLDIM SELECTEDSELECTED = Request.Form ("Options") Establish a record set ("OPTIONST) object, open object with method Open, and modify the corresponding data set = server.createObject (" AdoDb.Recordset ") Data Table RESSEARCH, that is, the corresponding voting number increases 1SQL = "Update research set select" & selected & "= select" & selected & " 1 where id = 1" rOpen SQL, CONN, 3, 3 Clear Record from Memory Collection Object SET RS = Nothing Close Connection Conn.close Clear Connection Object from Memory Set Conn = Nothing Connection to Browse Survey Results The result .Redirect "ViewResult.asp" Elseresponse.write "vote failed: You have already voted, Thank you for your support! "End if elseresponse.write" voting failed tips: You forgot to choose! "End if%> Three, browse the survey results (ViewResult.asp)</p> <p>In this example, the bar chart is used to discuss the results of the survey. The method is to multiply the percentage value of the total vote account for the percentage value of the total voter, and the value derived as a bar chart bar.gif displayed (available for common maps) Icon tools make a small strip chart, or to one online Down). In order to give the percentage of the votes with two decimals, the four-rousen functions in VBScript were used in the program. For the sake of beauty, put the findings in the table in the table, as shown. The table is designed in the code given below.</p> <p>viewresult.asp <% set conn = server.createobject ( "ADODB.CONNECTION") conn.open "researchdb"%> <% dim rsdim sqldim select1dim select2dim select3dim select4dim select5dim select6dim select7dim totalset rs = server.createobject ( "adodb.recordset" SQL = "Select * from research where id = 1" RS.Open SQL, CONN, 1, 1 TOTAL = RS ("SELECT1") RS ("SELECT2") RS ("SELECT3") _ rs ("SELECT4 ") RS (" SELECT5 ") RS (" SELECT6 ") RS (" SELECT7 ") Judging whether the total number of tickets is 0, make sure the following division is effective if Total> 0 Thenselect1 = (RS (" SELECT1 ") / Total ) * 100select2 = (RS ("SELECT2") / total) * 100select3 = (RS ("SELECT3" / total) * 100select4 = (RS ("SELECT4" / total) * 100select5 = (RS ("SELECT5") / total * 100select6 = (RS ("SELECT6") / total) * 100select7 = (RS ("SELECT7) / TOTAL) * 100%> <p> Thank you for your participation, the following is the current survey results <P> ◇ Knowledge: <img src = bar.gif width = <% = int (SELECT1 * 5)%> Height = 4> <% = rs ("SELECT1")%> People account for <% = Round (SELECT1, 2) %>% <br> ◇学: <img src = bar.gif width = <% = int (SELECT2 * 5)%> Height = 4> <% = rs ("SELECT2")%> People account for <% = Round (SELECT2, 2)%>% <br> ◇ Money: <img src = bar.gif width = <% = int (SELECT3) * 5%> Height = 4> <% = rs ("SE LeCT3 ")%> People account for: <% = Round (SELECT3, 2)%>% <br> ◇ love: <img src = bar.gif width = <% = int (select4) * 5%> Height = 4> <% = rs ("SELECT4")%> People account for: <% = Round (SELECT4, 2)%>% <br> ◇ Ideal: <img src = bar.gif width = <% =</p> <p>INT (SELECT5) * 5%> Height = 4> <% = rs ("SELECT5")%> People account for: <% = Round (SELECT5, 2)%>% <br> ◇ Democratic awareness: <img src = bar .gif width = <% = int (SELECT6)% * 5> Height = 4> <% = RS ("SELECT6")%> People account for: <% = round (SELECT6, 2)%>% <br> ◇ Science Thought: <img src = bar.gif width = <% = int (SELECT7)% * 5> Height = 4> <% = rs ("SELECT7")%> People account for <% = round (SELECT7, 2)% >% </ p> <p align = "center"> already have: <% = total%> people participated in the survey <br> <br> [<a href = "javascript: window.close ()"> Close < / a>】 </ p> <p> <% else response.write "End if rs.close set rs = NothingConnclose Set Conn = NothingConnClose Set CONN = Nothing%></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-63605.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="63605" 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.053</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 = '_2BwhviJbbnvLeSox_2B_2FGH6hmbOuGZCRhL2JVQDp8OqRCJuHYPqUEjZFzsN_2BLo67WLkqu9hv7sXHyaAkib33BzIKw_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>