Bonjour je me tourne vers vous car j'ai un soucis sur un programme html incorporant du javascript afin de réaliser une calculatrice banale.
voici mon code :
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
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title> Ma calculatrice</title>
<script type="text/javascript">
function resultat()
{
var x = 0;
x= eval(window.document.calculatrice.affiche.value);
window.document.calculatrice.affiche.value = x;
}
function ajouter (signe)
{
window.document.calculatrice.affiche.value =
window.document.calculatrice.affiche.value + signe;
}
</script>
</head>
<body>
<form name="calculatrice" action="javascript" method="post">
<table border="1">
<td> <input name="affiche" size="20" maxlength="20"/> </td>
</table>
<table border="1">
<tr>
<td> <input type="button" value="7" onClick="ajouter('7')"/> </td>
<td> <input type="button" value="8" onClick="ajouter('8')"/> </td>
<td> <input type="button" value="9" onClick="ajouter('9')"/> </td>
<td> <input type="button" value="+" onClick="ajouter('+')"/> </td>
</tr>
<tr>
<td> <input type="button" value="4" onClick="ajouter('4')"/> </td>
<td> <input type="button" value="5" onClick="ajouter('5')"/> </td>
<td> <input type="button" value="6" onClick="ajouter('6')"/> </td>
<td> <input type="button" value="-" onClick="ajouter('-')"/> </td>
</tr>
<tr>
<td> <input type="button" value="1" onClick="ajouter('1')"/> </td>
<td> <input type="button" value="2" onClick="ajouter('2')"/> </td>
<td> <input type="button" value="3" onClick="ajouter('3')"/> </td>
<td> <input type="button" value="*" onClick="ajouter('*')"/> </td>
</tr>
<tr>
<td> <input type="button" value="=" onClick="resultat()"/> </td>
<td> <input type="button" value="0" onClick="ajouter('0')"/> </td>
<td> <input type="button" value="/" onClick="ajouter('/')"/> </td>
</tr>
<tr>
<td> <input type="reset" value="C"/> </td>
</tr>
</form>
</table>
</body>
</html> |
Impossible de le valider au W3C il me trouve des erreurs que je n'arrive pas à comprendre comme. Line 29, Column 17: there is no attribute "name"
<form name="calculatrice" action="javascript" method="post">
ou le " devant le calculatrice et en erreur.
Ainsi que les > de table form quand je veux fermer les balises.
Je suis dans l'impasse :/
Partager