标签:
投票界面代码
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> </head> <body> <?php include "function/unionsql-function.php"; if(isset($_POST[‘submit‘])&& isset($_POST[‘atr‘])) { $atr=$_POST[‘atr‘]; foreach($atr as $i) { $s3="select number from dy where code=$i[0]"; $s3=unionsql($s3); $s3=$s3[0][0]+1; $s4="update dy set number=$s3 where code=$i[0]"; $s4=unionsql($s4); } } $ssum="select sum(number) from dy"; $ssum=unionsql($ssum); $s1="select * from dytitle"; $s1=unionsql($s1); if($s1[0][2]==1) $type="checkbox"; else $type="radio"; $s2="select * from dy where titleid={$s1[0][0]}"; $s2=unionsql($s2); ?> <div>标题:<?php echo $s1[0][1] ?></div> <div id=‘a‘ style="display:block;"> <form action=‘‘ method=‘post‘> <?php echo "<table>"; foreach($s2 as $i) { echo"<tr> <td><input type=$type value=‘$i[0]‘ name=‘atr[]‘ /></td> <td>$i[1]</td> </tr>"; } echo "</table>"; ?> <input type="submit" value="提交" name="submit" /> <input type="button" value="投票结果" onclick="ck()" /> </form> </div> <div id="b" style="display:none;"> <?php echo "<table>"; foreach($s2 as $i) { $snumber="select number from dy where code=$i[0]"; $snumber=unionsql($snumber); $j=round($snumber[0][0]/$ssum[0][0]*100)."%"; echo"<tr> <td>$i[1]</td> <td>$i[2]</td> <td> <div style=‘width:150px; height:10px; background-color:#666;‘> <div style=‘width:{$j}; height:10px; background-color:#F00;‘></div> </div> </td> <td>$j</td> </tr>"; } echo "</table>"; ?> <input type="button" value="返回投票" onclick="fh()" /> </div> </body> </html> <script type="text/javascript"> function ck() { var a=document.getElementById(‘a‘); var b=document.getElementById(‘b‘); a.style.display="none"; b.style.display="block"; } function fh() { document.getElementById("a").style.display="block"; document.getElementById("b").style.display="none"; } </script>
标签:
原文地址:http://www.cnblogs.com/lovling/p/5470408.html