|
|
|
|
Bonjour,
Je dois afficher 3 chiffres au hasard entre 0 et 9 sauf la ca m'affiche undefined... quelqu'un peu m'aider je suis débutante ... voila mon code... merci
<!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>
<LINK HREF="Base.CSS" REL="stylesheet" TYPE="text/css">
<title>Tp2 IFT1144, numéro 1
</title>
</head>
<body>
<table border=0 cellspacing=0 cellpadding=10 cols=2 width="92%">
<tr>
<td width="1%">
<img border="0" src="UMlogo.gif" width="110" height="50" alt="UdeM"></a></td>
</td>
<td width="100%"><h1> ift1144, tp2 numéro 1 </h1>
</td>
</tr>
<tr>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=10 cols=4 width="100%">
<tr>
</tr>
<tr>
<td width="1%">
</td>
<td width="99%"><h2> Tirage de la Quotidienne 3 chiffres </h2>
</td>
</tr>
</table>
<script>
var qu1, qu2, qu3;
function chiffreAleatoire (max){
return Math.floor(math.random() *(max*10+1));
}
qu1= chiffreAleatoire(9);
qu2= chiffreAleatoire(9);
qu3= chiffreAleatoire(9);
</script>
<table border="1" width="50%" align="center">
<tr>
<td align="center"> <script>document.write(qu1)</script></td>
<td align="center"> <script>document.write(qu2)</script></td>
<td align="center"> <script>document.write(qu3)</script></td>
</tr>
</table
<body>
</body>
</html>
Configuration: Windows XP Internet Explorer 7.0
Répondre à CrazyWorld
|
Je viens de te modifier ta source en utlisant du php à la place du JavaSvcript
<? mt_srand((float) microtime()*1000000); $nb1= mt_rand(0, 9); $nb2= mt_rand(0, 9); $nb3= mt_rand(0, 9); ?> <!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> <LINK HREF="Base.CSS" REL="stylesheet" TYPE="text/css"> <title>Tp2 IFT1144, numéro 1 </title> </head> <body> <table border=0 cellspacing=0 cellpadding=10 cols=2 width="92%"> <tr> <td width="1%"> <img border="0" src="UMlogo.gif" width="110" height="50" alt="UdeM"></a></td> </td> <td width="100%"><h1> ift1144, tp2 numéro 1 </h1> </td> </tr> <tr> </tr> </table> <table border=0 cellspacing=0 cellpadding=10 cols=4 width="100%"> <tr> </tr> <tr> <td width="1%"> </td> <td width="99%"><h2> Tirage de la Quotidienne 3 chiffres </h2> </td> </tr> </table> <table border="1" width="50%" align="center"> <tr> <td align="center"><? echo $nb1;?></td> <td align="center"><? echo $nb2;?></td> <td align="center"><? echo $nb3;?></td> </tr> </table> <br> <br><h3>Travail effectué par: Geneviève Hénault</h3> </body> </html> Et ca marche ^^ |