I have found the following code and wish to have it do a POST instead of the GET
can someone tell me what needs changing so this does a POST
ajax.php
<?php
if (is_numeric($_GET['client_id'])) {
include("database.php");
$query="SELECT * FROM `client_addresses` WHERE `client_id` = '". db_input($_GET['client_id']) ."'";
$result=mysql_query($query);
?><select name="client_address">
<option>Select address</option><?
while( $res_array = mysql_fetch_assoc($result) ) {
echo "<option value=\"".$res_array['client_address']."\">".$res_array['client_address']."</option>";
} ?>
</select>
<?
}
?>
index.php
<html>
<head>
<script language="JavaScript" type="text/javascript">
function display_data(client_id) {
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null) {
alert ("Your browser does not support AJAX!");
return;
}
var url="ajax.php";
url=url+"?client_id="+client_id;
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete") {
document.getElementById('employ_data').innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function GetXmlHttpObject() {
var xmlhttp=null;
try {
// Firefox, Opera 8.0+, Safari
xmlhttp=new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlhttp;
}
</script>
</head>
<body>
<form>
<select name="client_name" onchange="display_data(this.value);">
<option>Select client</option>
<?php
include("database.php");
$customer_id = "11";
$query="SELECT * FROM `client_names`";// WHERE `customer_id` = '". $customer_id ."'
$result=mysql_query($query);
while( $res_array = mysql_fetch_assoc($result) ) {
echo "<option value=\"".$res_array['client_id']."\">".$res_array['client_id']."</option>";
}
?>
</select>
<div id="employ_data"><div>
</form>
</body>
</html>