I can not for the life of me get an ajax example/tutorial to work. I have tried dozens including prototype library and JQuery.
Here is my latest attempt:
<!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>Easy</title>
<script type="text/javascript">
function getXMLHTTP() {
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function habadashery(strURL) {
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
document.getElementById("teamH").innerHTML=req.responseText;
alert(req.value);
}
else {
alert("There was a problem while using XMLHTTP:\n");
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
</script>
</head>
<body>
<?php
include("sparkplug.php");
$result = mysql_query("SELECT DISTINCT (team) FROM member_data2011spring WHERE division='a' ORDER BY team ASC")
or die(mysql_error());
$options="";
while($row = mysql_fetch_array( $result )) {
$team=$row["team"];
$options.="<option value=\"$team\">".$team;
}
?>
<p> </p>
<form id="emsw" class="formFields" action="">
<select class="differ" name="teamHome" id="teamH" onchange="habadashery('findplayer.php?teamH='+this.value)">
<option value="0" selected="selected">Choose Home Team<?=$options?></option>
</select>
<div id="playerH"></div>
</form>
</body>
</html>
As you can see I am trying to alert the variable teamH but I keep getting an undefined in the alert. I also tried a static drop down and I received the same undefined alert.
Any suggestions as how I get that variable to contain my drop down choice?
thanks,
rad1964