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
| <?php
function genere($min,$max)
{
if (isset($_POST['generer']))
{
echo rand($min,$max);
}
}
?>
<!--Code HTML du formulaire-->
<form action="#" method="post">
<fieldset>
<legend><b>Calculatrice</b></legend>
<table>
<tbody>
<tr>
<th>Nombre X</th>
<td><input type="number" name="nb1" size="30" VALUE="<?=genere(1,10)?>"/></td>
</tr>
<tr>
<th>Nombre Y</th>
<td><input type="number" name="nb2" size="30" VALUE="<?=genere(11,100)?>"/></td>
</tr>
<tr>
<th>Choisissez !</th>
<td>
<input type="submit" name="calcul" value="Addition x+y" />
<input type="submit" name="calcul" value="Soustraction x-y" />
<input type="submit" name="calcul" value="Multiplication x-y" />
<input type="submit" name="calcul" value="Division x/y" />
<input type="submit" name="calcul" value="Puissance x^y" />
<input type="submit" name="generer" value="Générer" />
</td>
</tr>
</tbody>
</table>
</fieldset>
</form> |