John Higgins John Higgins - 1 year ago 103
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?



Answer Source

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;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download