<html>
<head>
<title>投票</title>
<META http-equiv=Content-Language content=zh-cn>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style type="text/css">
<!--
.poll {font-size: 10pt;display:block}
.pollresult {font-size: 12pt;display:none}
-->
</style>
<?php
include_once("server1.server.php"); #servidor para XAJAX
$xajax->printJavascript();
?>
</head>
<body>
<script language=javascript>
function back() {
document.getElementById('poll').style.display = 'block';
document.getElementById('pollresult').style.display = 'none';
document.getElementById('pollresult').innerHTML = '';
}
</script>
<div id=pollresult class=pollresult>
</div>
<?php
global $db;
$poll = $db->getRow("select * from TBL_POLL order by poll_id desc limit 1");
$poll_id = $poll["poll_id"];
$pollitems = $db->getAll("select * from TBL_POLLITEM where poll_id=$poll_id");
?>
<div id=poll class=poll>
<form id="pollForm" action="javascript:void(null);" οnsubmit="onSubmit();">
<?php echo $poll["title"]; ?><br>
<?php for ($i = 0, $count = count($pollitems); $i < $count; $i++) { ?>
<input type="radio" style="background-color : #CCCCCC;" name="pollitem" value="<?php echo $pollitems[$i]['pollitem_id'] ?>"><?php echo $pollitems[$i]['content'] ?><br>
<?php } ?>
<input type="hidden" name="poll_id" value="<?php echo $poll_id; ?>">
<input type="submit" value="enter">
</form>
<script language=javascript>
function onSubmit() {
xajax_poll(xajax.getFormValues("pollForm"));
document.getElementById('poll').style.display = 'none';
document.getElementById('pollresult').style.display = 'block';
}
</script>
</div>
</body>
</html>
服务器端