0

JavaScript DOM

I have an error and I don't know how to fix it, This is my JavaScript code: var codigo = Math.round(Math.random()*(9999-1000)+parseInt(1000)); intentos = 0; console.log(codigo); var formulario = document.getElementById("form"); var getValue = function(){ var x = document.getElementById("numero").value; var aciertos = 0, coincidencias = 0; if (propuesta != codigo) { intentos = intentos + 1; for (var i in codigo.length){ if (propuesta.charAt(i) == codigo.charAt(i)){ aciertos = aciertos + 1; } else if (propuesta.charAt(i) in codigo){ coincidencias = coincidencias + 1 } } alert("Successes: " + aciertos + " Coincidences: " + coincidencias); alert("propon otro numero"); } }; In the HTML document I have a form with an input and a send button but as soon as the form is sent it saves the value of the variable and it is automatically deleted, how do I for not delete it?

17th Feb 2020, 8:04 PM
AlexRos
AlexRos - avatar
3 Respuestas
0
I resolve it, even so Thanks (and it’s almost whole code)😂 I only change the input to a prompt😂
19th Feb 2020, 5:19 PM
AlexRos
AlexRos - avatar
+ 1
Can you send a Link of your whole code
19th Feb 2020, 5:11 PM
Chi Hydra
Chi Hydra - avatar
+ 1
😂
19th Feb 2020, 5:21 PM
Chi Hydra
Chi Hydra - avatar