I know some ajax but do I have anything wrong with it.
Code:
<script type="text/javascript">
function ajaxGet()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById('label').value = xmlHttp.responseText;
//ajaxGetL();
}
}
//alert("Selected: " + document.getElementById("ajax1").value);
var names = document.getElementById("names");
xmlHttp.open("GET","showAjax.php?label=" + names.options[names.selectedIndex].value + "&rand=" + Math.random(),true);
xmlHttp.send(null);
}
</script>
PHP Code:
<?php
require('database.php');
if(isset($_GET['country']))
{
$country = mysql_real_escape_string($_GET['country'],$link);
$query = mysql_query("SELECT `arena` FROM `arenas` WHERE `country` = '".$country."' ORDER BY arena") or die("ERROR 1");
while($list = mysql_fetch_assoc($query))
{
echo "<option value=\"".$list['arenas']."\">".$list['arenas']."</option>";
}
}
?>
PHP Code:
print '<tr>';
print '<td class="rowheading">Country</td>';
print '<td class="row3" colspan="2"><select name="countryid" class="dropdown" onChange="ajaxGet();"><option value=0>- Select -</option>';
$query = 'SELECT * FROM arenas GROUP BY `country` ORDER BY `country`';
$result = mysql_query ( $query );
while ( $row = mysql_fetch_assoc ( $result ) )
{
print "<option value=\"".$row['country']."\">".$row['country']."</option>\r";
}
print '</select></td>';
print '</tr>';
print '<tr>';
print '<td class="rowheading">Arena</td>';
print '<td class="row3" colspan="2"><div id="arenaajax"><select name="arena" class="dropdown"><option value="0">- Select Arena -</select><input type="hidden" name="location" value="0"></div></td>';
print '</tr>';