日期:2014-05-17 浏览次数:20652 次
<?php /* Created on [2012-5-16] */ #查询标题信息 $sql="select * from table"; $res=mysql_query($sql); if(!$res) die("SQL: {$sql} <br>Error:".mysql_error()); if(mysql_affected_rows() > 0){ $titles = array(); while($rows = mysql_fetch_array(MYSQL_ASSOC)){ array_push($titles,$rows); } } ?> <table border=1> <?php foreach($titles as $row_Recordset_task){ ?> <tr> <td> <a href="javascript:void(0)" onclick="record(<?=$row_Recordset_task['TID']?>)" > <?=$row_Recordset_task['csa_title']?> </a> </td> </tr> <?php } ?> </table> <div id="show"></div> <form name="frm"> <select name="s1" onChange="redirec(this.value)"> <option selected>请选择</option> <option value="1">内科</option> <option value="2">内科</option> <option value="3">内科</option> </select> <div id="s2"></div> </form> <script> //Ajax var xmlHttp; function createXMLHttpRequest() { if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } } function record(id){ createXMLHttpRequest(); url = "action.php?id="+id+"&ran="+Math.random(); method = "GET"; xmlHttp.open(method,url,true); xmlHttp.onreadystatechange = show; xmlHttp.send(null); } function show(){ if (xmlHttp.readyState == 4){ if (xmlHttp.status == 200){ var text = xmlHttp.responseText; document.getElementById("s2").innerHTML = text; }else { alert("response error code:"+xmlHttp.status); } } } </script> <?php #action.php if(isset($_GET['id'])){ $sql="select * from table where id=".