Hi guys im trying to get this simple page to work and i dont know why it does not owrk. im new to ajax
i crreated a form and then i use ajax to call a php script which prints out options for the select.
however when i submit my php can not capture the values! but my js sees the value, i use and alert to display it when it is changed and it shows the appropriate value. forexample $_POST['testing']
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="javascript"> function checking() { var xmlHttp = false; try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { try { xmlHttp = new XMLHttpRequest(); } catch(e) { altert("your browser is too old") } } } var obj = document.getElementById("testing"); xmlHttp.open("GET","select.php"); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { obj.innerHTML = xmlHttp.responseText; } } xmlHttp.send(null); } function castvalue(v) { alert(v); } </script> <? if($_POST['submit']) { echo("Testing: - " . $_POST['testing'] . " -"); } ?> </head> <body onload="checking();"> <form method="post"> <select id="testing" onchange="castvalue(this.value);"> <div id="grab" name="grab"> </div> </select> <input type="submit" id="submit" name="submit" value="submit" /> </form> </body> </html>
select.php
PHP Code:
Code:<? include("../include/cms/connect.inc.php"); $platformlist = "SELECT * FROM platform"; $myplatformlist = mysql_query($platformlist) or die(mysql_error()); while($queryplatformlist = mysql_fetch_array($myplatformlist)) { echo " <option value=\"" . $queryplatformlist["id"] . "\">" . $queryplatformlist["name"] . "</option>"; } mysql_free_result($myplatformlist); mysql_close(); ?>
Plz plz help me~


Reply With Quote
Bookmarks