<!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>
<script type="text/javascript">
var xhr = null;
if(window.XMLHttpRequest) // Firefox et autres
xhr = new XMLHttpRequest();
else if(window.ActiveXObject) {// Internet Explorer
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e1) {
xhr = null;
}
}
} else {// XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
}
var op;
function Operation() {
xhr.open("GET","Exercice2.php?val1="+document.getElementById("val1").value+"
&val2="+document.getElementById("val2").value+"&op="+document.getElementById("op").value,true);
xhr.onreadystatechange=function() {
if(xhr.readyState==4
&& xhr.status==200) {
document.getElementById(op).innerHTML=document.getElementById(op).innerHTML+xhr.responseText+"<br>";
}
}
op=document.getElementById("op").value;
xhr.send(null);
}
</script>
</head>
<body>
<input type="text" id="val1" size="4">
<select id="op">
<option value="add">+
</option>
<option value="sou">-
</option>
<option value="mul">*
</option>
<option value="div">/
</option>
</select>
<input type="text" id="val2" size="4">
<input type="button" value="=" onclick="Operation();"><br/><br/>
<table border="1">
<tr>
<td><b>Additions
</b></td>
<td><b>Soustractions
</b></td>
<td><b>Multiplications
</b></td>
<td><b>Divisions
</b></td>
</tr>
<tr valign="top">
<td><div id="add"></div></td>
<td><div id="sou"></div></td>
<td><div id="mul"></div></td>
<td><div id="div"></div></td>
</tr>
</table>
</body>
</html>