John Higgins John Higgins - 9 months ago 68
HTML Question

Display real time results in input box

I am trying to display the results of an input in real time in another disabled input box and am not having much luck. Code below:

var inputBox = document.getElementById('input');

inputBox.onkeyup = function(){
document.getElementById('output').innerHTML = inputBox.value*2;

<input type='text' id='input'>

<input type='text' id='output' disabled>

Can anyone help?




Try adding a listener and use value instead of innerHTML:

document.getElementById('input').addEventListener("keyup", myFunction);

var inputBox = document.getElementById('input');

function myFunction(){
    document.getElementById('output').value = inputBox.value*2;