Bonjour à tous !
Voilà mon problème est le suivant j'ai une suite de boutons chacun de ces boutons vont de 1 à 20.
j'ai deux textbox une qui affiche la valeur sur laquelle on a cliqué et l'autre qui indique un plus ou moins, je n'arrive pas à récupérer la valeur du bouton et à la comparer à celle enregistrée par l'ordinateur.
Voilà mon problème est le suivant j'ai une suite de boutons chacun de ces boutons vont de 1 à 20.
j'ai deux textbox une qui affiche la valeur sur laquelle on a cliqué et l'autre qui indique un plus ou moins, je n'arrive pas à récupérer la valeur du bouton et à la comparer à celle enregistrée par l'ordinateur.
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mon Big Guess</title>
<link rel="stylesheet" type="text/css" href="flowbigguess.css">
<script type="text/javascript" src="codebigguess.js"></script>
</head>
<body>
<h1 id="titre">Mon Big Guess</h1>
<div id="tableau">
<input type="text" id="afficheurleft">
<input type="text" id="afficheurright">
<button type="button" class="touche" onclick="affiche('0')">0</button>
<button type="button" class="touche" onclick="affiche('1')">1</button>
<button type="button" class="touche" onclick="affiche('2')">2</button>
<button type="button" class="touche" onclick="affiche('3')">3</button>
<button type="button" class="touche" onclick="affiche('4')">4</button>
<button type="button" class="touche" onclick="affiche('5')">5</button>
<button type="button" class="touche" onclick="affiche('6')">6</button>
<button type="button" class="touche" onclick="affiche('7')">7</button>
<button type="button" class="touche" onclick="affiche('8')">8</button>
<button type="button" class="touche" onclick="affiche('9')">9</button>
<button type="button" class="touche" onclick="affiche('10')">10</button>
<button type="button" class="touche" onclick="affiche('11')">11</button>
<button type="button" class="touche" onclick="affiche('12')">12</button>
<button type="button" class="touche" onclick="affiche('13')">13</button>
<button type="button" class="touche" onclick="affiche('14')">14</button>
<button type="button" class="touche" onclick="affiche('15')">15</button>
<button type="button" class="touche" onclick="affiche('16')">16</button>
<button type="button" class="touche" onclick="affiche('17')">17</button>
<button type="button" class="touche" onclick="affiche('18')">18</button>
<button type="button" class="touche" onclick="affiche('19')">19</button>
<button type="button" class="touche" onclick="affiche('20')">20</button>
</div>
</body>
</html>
Code:
var rand = Math.floor(Math.random()*20+1);
var tours = 0;
var nombre;
var a;
document.getElementById('afficheurleft').addEventListener('onclick', nombre);
function nombre() {
nombre = document.getElementById('button').value;
//parseInt(nombre);
if (nombre === rand) {
alert('T\'as gagné en '+ tours +' tours fdp');
} else if (nombre < rand) {
alert('C\'est + pd');
tours++;
} else if (nombre > rand) {
alert('C\'est - enculé');
tours++;
} else {
alert('C\'est pas un nombre putain.');
}
}
/* function affiche(par)
{
a = document.getElementById("afficheurleft");
if(par=='c'){
a.value='';
}
else {
a.value=a.value+par;
}
console.log(affiche);
} */