-3
I’ve been trying to make whatever I type appear inside another input, but I couldn’t. The point is I got this code here, it runs and it works right, but in my real code it doesn’t run.
window.oninput = function(event){
var campo = event.target.id; // pega o id do campo que chamou o evento
if(campo == "a"){
document.querySelector('#a-1').value = document.querySelector('#a').value;
}else if(campo == "a-1"){
document.querySelector('#a').value = document.querySelector('#a-1').value;
}
};
<h2>Este campo é diretamente automático</h2>
<input type="text" id="a"> oninput: <input type="text" id="a-1"><br><br>
It worked!!! Thank you my friend
– JV10
With onkeypress the first typed in the field does not go to the other field. From then on the last typed will not, that’s if you type ABCD in the other field is like ABC
– user60252