当前位置: 首页 > 图文教程 > 网络编程 > AJAX技术 > 实现一个基于Ajax的调查程序

AJAX技术
ajax和asp.net的配置文件
关天asp.net ajax beta中在updatepnael中注册脚本的解决方案
ASP.NET AJAX Beta2 调用本地WebService的一些改变
Ajax+GridView+Xml的简易留言薄
PHP和AJAX打造高级RSS聚合器
注册起动脚本,ASP.NET AJAX的一项重要功能!
使用Ajax时的十个常犯的错误
如何在ASP.Net Ajax中调用WebService
xmlHTTP xmlDOC 与 C#中DataSet的结合 实现AJAX简单示例
争论:Ajax技术是否即将没落?
Ajax:拥抱JSON,让XML走开
AJAX有没有未来?
Ajax 框架ZK 2.2 发布
利用ProtoType框架完成的一个下拉框(asp:DropDownList)联动的AJAX例子
在ASP.NET AJAX中别使用mode=Legacy
ASP.NET AJAX RC Tip:页面中无UpdatePanel时UpdateProgress创建出错问题
ECMAScript基础类以及Asp.net Ajax对类Object的扩展
Asp.net Ajax 中的脚本错误: Sys未定义 的解决方法
基于AJAX的ASP.NET聊天室-如何建立共识
解开Ajax技术生命中的达芬奇密码

AJAX技术 中的 实现一个基于Ajax的调查程序


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 79 ::
收藏到网摘: n/a

<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);" onsubmit="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> 
服务器端
function poll($formData){
  global $db;
  $tmp="";
  $objResponse = new xajaxResponse();
  
  $poll_id = $formData[’poll_id’];

  $pollitem_id = $formData[’pollitem’];
  
  if($pollitem_id > 0 && $poll_id > 0) { 
   $db->query("update ".TBL_POLLITEM." set count=count+1 where pollitem_id = $pollitem_id");                  
  }
  
  $poll = $db->getRow("select * from TBL_POLL where poll_id = $poll_id");
  $pollitems = $db->getAll("select * from TBL_POLLITEM where poll_id=$poll_id");
  
  
  $tmp&nbs