asp做问卷调查

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

asp做问卷调查投票新建一个文件夹将下列文件按照提示放到文件夹中在文件夹中建一个名为img的文件夹图:将此图片存入img文件夹名为bar.gif首先是数据库链接文件coon.asp:%'连接数据库开始dimconn,rs,sql'onerrorresumenextdbpath=server.mappath(data.mdb)setconn=server.createobject(adodb.connection)conn.openPROVIDER=Microsoft.jet.OLEDB.4.0;datasource=&dbpath'创建记录对象setrs=server.createobject(adodb.recordset)%制作一个用来投票的页面add.asp:htmlheadmetahttp-equiv=Content-Typecontent=text/html;charset=gb2312title问卷调查/titlelinkhref=css.cssrel=stylesheettype=text/cssstyletype=text/css!--body,td,th{font-family:宋体;font-size:14px;}--/style/headbodyformname=form1method=postaction=updata.aspcenterdivclass=bigboxstyle=border:#3399FF3pxdouble;width:500px;padding:5pxtablewidth=554border=0trtd1.请问您公司的性质是什么?/td/trtrtdinputtype=checkboxname=ask1value=A国家机关A国家机关/td/trtrtdinputtype=checkboxname=ask1value=B全民企业单位B全民企业单位/td/trtrtdinputtype=checkboxname=ask1value=C私营企业C私营企业/td/trtrtdinputtype=checkboxname=ask1value=D个体商户D个体商户/td/trtrtdinputtype=checkboxname=ask1value=E外资企业E外资企业/td/tr/table/divdivclass=bigboxstyle=border:#3399FF3pxdouble;width:500px;padding:5pxtablewidth=554border=0trtd2.请问您公司的人数是多少?/td/trtrtdinputtype=checkboxname=ask2value=A0-10A0-10/td/trtrtdinputtype=checkboxname=ask2value=B10-30B10-30/td/trtrtdinputtype=checkboxname=ask2value=C30-50C30-50/td/trtrtdinputtype=checkboxname=ask2value=D50-100D50-100/td/trtrtdinputtype=checkboxname=ask2value=E100以上E100以上/td/tr/table/divcenterinputname=Submittype=submitclass=buttonvalue=投票ahref=show.asp查看结果/a/center/form/body/html单击投票按钮FORM表单将数据提交给updata.asp页面进行处理updata.asp:!--#includefile=conn.asp--htmlheadmetahttp-equiv=Content-Typecontent=text/html;charset=gb2312title投票成功/title/headbodyp%str1=Request.Form(ask1)str2=Request.Form(ask2)ifstr1=orstr2=thenresponse.writescriptlanaguage=javascriptalert('每题至少选一项,请填写完整');history.back();/scriptresponse.End()endifsetrs=server.createobject(adodb.recordset)sql=select*fromaskItemwhereaId=1rs.opensql,conn,1,1dowhilenotrs.eofifinstr(str1,rs(askItem))0thensql=updateaskItemsetsubNum=subNum+1whereid=&rs(id)conn.execute(sql)endifrs.movenextlooprs.closesql=select*fromaskItemwhereaId=2rs.opensql,conn,1,1dowhilenotrs.eofifinstr(str2,rs(askItem))0thensql=updateaskItemsetsubNum=subNum+1whereid=&rs(id)conn.execute(sql)endifrs.movenextlooprs.closeResponse.Redirect(show.asp)%/pp /p/body/htmlupdata页面将数据处理后重定向到show.asp来显示投票结果show.asp:!--#includefile=conn.asp--!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN==Content-Typecontent=text/html;charset=gb2312/title投票结果/titlestyletype=text/css!--.STYLE1{font-family:黑体;font-size:24px;color:#FF0000;}--/style/headbodydivclass=bigboxstyle=border:#3399FF3pxdouble;width:560px;padding:5pxtablewidth=100%border=1cellspacing=0cellpadding=3bordercolordark=#FFFFFFbordercolorlight=#000000trtdcolspan=4align=center1.请问您公司的性质是什么?/td/trtrtdwidth=42%align=center选项/tdtdwidth=34%align=center柱状图/tdtdwidth=10%align=center票数/tdtdwidth=14%align=center%/td/tr%setrs=server.createobject(adodb.recordset)sql=select*fromaskItemwhereaId=1rs.opensql,conn,1,1Dimtopnumtopnum=0dowhilenotrs.eoftopnum=topnum+rs(subNum)rs.movenextlooprs.closesql=select*fromaskItemwhereaId=1rs.opensql,conn,1,1dowhilenotrs.eof%trtd%=rs(askItem)%/tdtdimgsrc=img/bar.gifwidth=%Iftopnum=0ThenResponse.Write(1)ElseResponse.Write(int(rs(subNum)/topnum*100))endif%height=10/tdtdalign=center%=rs(subnum)%/tdtdalign=center%IftopNum=0ThenResponse.Write(-)ElseResponse.Write(int(rs(subNum)/topNum*1000)/10)endif%%/td/tr%rs.movenextlooprs.closesetrs=nothing%/table/divdivclass=bigboxstyle=border:#3399FF3pxdouble;width:560px;padding:5pxtablewidth=100%border=1cellspacing=0cellpadding=3bordercolordark=#FFFFFFbordercolorlight=#000000trtdcolspan=4align=center2.请问您公司的人数是多少?/td/trtrtdwidth=42%align=center选项/tdtdwidth=34%align=center柱状图/tdtdwidth=10%align=center票数/tdtdwidth=14%align=center%/td/tr%setrs=server.createobject(adodb.recordset)sql=select*fromaskItemwhereaId=2rs.opensql,conn,1,1dimtopnum2topnum2=0dowhilenotrs.eoftopnum2=topnum2+rs(subNum)rs.movenextlooprs.closesql=select*fromaskItemwhereaId=2rs.opensql,conn,1,1dowhilenotrs.eof%trtd%=rs(askItem)%/tdtdimgsrc=img/bar.gifwidth=%Iftopnum2=0ThenResponse.Write(1)ElseResponse.Write(int(rs(subNum)/topnum2*100))endif%height=10/tdtdalign=center%=rs(subnum)%/tdtdalign=center%IftopNum2=0ThenResponse.Write(-)ElseResponse.Write(int(rs(subNum)/topNum2*1000)/10)endif%%/td/tr%rs.movenextlooprs.closesetrs=nothing%/table/div/body/html建立Access数据库首先建一个名为data的数据库在data中建两个表分别名为:askItem和askTitleaskTitle中id自动编号askTitle文本askItem中id自动编号aID数字askItem文本subNum数字

1 / 9
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功