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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
<script type="text/javascript">
function getElement(id)
{
var Elem;
if(document.getElementById)
{
if (typeof document.getElementById(id) == "object")
Elem = document.getElementById(id);
else
Elem = void(0);
}
else if(document.all)
{
if (typeof document.all[id] == "object")
Elem = document.all[id];
else
Elem = void(0);
}
else if(document.layers)
{
if (typeof document[id] == "object")
Elem = document[id];
else
Elem = void(0);
}
else Elem = void(0);
return Elem;
}
var xhr = null;
function getXhr()
{
if (window.XMLHttpRequest)
{
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject) // if IE
{
var ieversions = ['Msxml2.XMLHTTP',
'Microsoft.XMLHTTP',
'Msxml2.XMLHTTP.5.0',
'Msxml2.XMLHTTP.4.0',
'Msxml2.XMLHTTP.3.0'
];
for(var i=0; !xhr && i<ieversions.length; i++)
{
try
{
xhr = new ActiveXObject(ieversions[i]);
}
catch(e)
{
xhr = null;
}
}
}
if(!xhr)// XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
}
/**
* Méthode qui sera appelée sur le click du bouton
*/
function requete(page,select,form,target,target1,target2,target3,target4)
{
getXhr();
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
if(xhr.status == 200 || xhr.status == 304)
eval(xhr.responseText);
}
};
xhr.open("POST",page,true);
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.send("form="+escape(form)+"&type="+escape(select.id)+"&id="+escape(select.value)+"&target="+escape(target)+"&target1="+escape(target1)+"&target2="+escape(target2)+"&target3="+escape(target3)+"&target4="+escape(target4));
}
</script>
.........
<select name="oam" id="oam" onClick="javascript:requete('requete_oam.php',this,'formulaire');" />
<?php
$oam=$_GET["oam"];
echo '<option value="'.$oam.'">'.$oam.'</option>';
while ($row1= mysql_fetch_array($result1, MYSQL_ASSOC))
{$var1= $row1["oam"];
echo '<option value="'.$var1.'">'.$var1.'</option>';
}
?>
</select> |
Partager