Question
Trying to use an HTML form linked to javascript
When I'm trying my page, when I fill my form it instantly reload and nothing happen, I can see the glimse of an error in the console but it disapears instantly...
I have been trying to modify my form but nothing seems to work
// je gere la generation de nombre
function donneAlea(){
nombre = Math.floor(Math.random()*6+1)
return nombre
}
// je gere la banque
function management(somme,pari,victoire){
if(victoire){
somme = somme + pari
}
else{
somme -= pari
}
return somme
}
// je m'ocuppe du bouton
let pression = document.getElementById('presse');
pression.onclick = function(){
let baliseNom =getElementById('lenom');
let nom = baliseNom.value
let body = document.querySelector('body')
body.innerHTML(`<p>test ${nom}</p>`)
}
console.log("test")
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Veux tu parier tout ton argent</title>
<script src = "script.js" defer></script>
</head>
<body>
<header>
<h1>La chance souris aux audacieux</h1>
<p> Tu ne gagnes rien si tu restes sur le côté</p>
</header>
<main>
<h2>Tu peux d'abord commencer par remplir es informations</h2>
<form id ='formulaire'>
<label for = "lenom" >Entrer votre nom</label>
<input id = 'lenom' type = "text" name ='lenom'>
<button id='presse'>envoyer</button>
</form>
</main>
</body>
</html>