1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
<?php
require_once '../include/class.lib.php';
$a = new lib();
echo $a->entete();
?>
<script lanuage="javascript" type="text/javascript">
function createRequestObject()
{
var ro;
ro = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
return ro;
}
var http = createRequestObject();
function GetIdCountry()
{
var ID_Country = document.getElementById('countryList').options[document.getElementById('countryList').selectedIndex].value;
return ID_Country;
}
function GetIdState()
{
var ID_State = document.getElementById('stateList').options[document.getElementById('stateList').selectedIndex].value;
return ID_State;
}
function sndReq(param,arg1,arg2)
{
var IdCountry = GetIdCountry();
http.open('get', './ajax.php?param='+param+'&IdCountry='+IdCountry);
http.onreadystatechange = handleResponse;
http.send(null);
}
function sndReq2(param)
{
var IdState = GetIdState();
http.open('get', './ajax.php?param='+param+'&IdState='+IdState);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse()
{
if (http.readyState == 4) {
var response = http.responseText;
var update = new Array();
if (response.indexOf('|') != -1) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
</script>
</head>
<body>
<form action="" method="POST">
<select id="countryList" name="countryList" size="1" onChange="sndReq('State')">
<option>Choisissez votre pays</option>
<?php
$queryCountry = $a->query('SELECT ID_Country, CountryName FROM Country ORDER BY CountryName ASC');
while ($resultCountry = mysql_fetch_array($queryCountry)) {
echo '<option value="'.$resultCountry['ID_Country'].'">'.$resultCountry['CountryName'].'</option>';
}
?>
</select><br>
<div id="State"></div>
<input type="submit">
</form>
<pre>
<?php
print_r($_POST);
?>
</pre>
</body>
</html> |
Partager