web下的投票系统设计

投票的选择的不确定性常常使我们在设计数据库的时候感到无从下手。所以我用的不是数据库保存的投票选项而是用的xml。用xml的设计的好处有很多,其中包括我们可以在其中保留很多的属性,在设计的时候,也可以进行多重选择都是一个很好的办法,用xsl对生成的xml文件进行解析这样的设计模式感觉很爽

我的xml的sample是这样的
<?xml version='1.0' encoding='gb2312' ?>
<?xml-stylesheet type='text/xsl' href='votesample.xsl'?>
<root>
<Questionname><![CDATA[我们的网站好看么?]]></Questionname>
<Choose select='radio' votekindid='1'>
  <ChooseItem value='a'><![CDATA[好看]]></ChooseItem>
  <ChooseItem value='b'><![CDATA[不好看]]></ChooseItem>
  <ChooseItem value='c'><![CDATA[不知道]]></ChooseItem>
  <ChooseItem value='d'><![CDATA[无所谓]]></ChooseItem>
</Choose>
</root>

xsl的sample:
<?xml version="1.0" encoding="gb2312" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="GB2312" />
<xsl:template match="/">
  <div>
    <div><xsl:value-of select="//root/Questionname" /></div>
    <table width="95%">
       <xsl:variable name="inputelement" select="//root/Choose/@select" />
       <form action="vote/record.asp" target="observe" method="post">
       <input type="hidden" name="votekindid" value="{//root/Choose/@votekindid}" />
          <xsl:for-each select="//root/Choose/ChooseItem">
      <tr>
         <td align="left"><input type="{$inputelement}" name="choise" value="{@value}"><xsl:if test="position()=1"><xsl:attribute name="checked">checked</xsl:attribute></xsl:if></input><xsl:value-of select="@value" /></td><td align="left" width="80%"><xsl:value-of select="." /></td>
      </tr>  
   </xsl:for-each>
      <tr><td align="center"></td><td align="left"><img src="images/index_left_button3.gif" οnclick="javascript:newWin('vote/result.asp?votekindid={//root/Choose/@votekindid}')" style="cursor:hand;" />  <input type="image" src="images/index_left_button4.gif" value="提交" οnclick="javascript:newWin()" /></td></tr>
       </form>
    </table>
  </div>
  <script language="javascript">
  <![CDATA[
  function newWin(url){
  if(url==''){
  newWindow=window.open("about:blank","observe","toolbar,resizable,scrollbars,dependent,width=500,height=420,left=150,top=80");
  newWindow.focus();}
  else{
  newWindow=window.open(url,"observe","toolbar,resizable,scrollbars,dependent,width=500,height=420,left=150,top=80");
  newWindow.focus();
  }
  }
  ]]>
  </script>
</xsl:template>
</xsl:stylesheet>

然后用一个vote表,记录一下值
用一个sql语句 select votechoose,count(votechoose) from vote where voteid=值 group by votechoose 进行统计

posted on 2006-05-26 12:42 csdn兔 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/liuxiaoyi666/archive/2006/05/26/409903.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值