Speedding Speedding - 8 months ago 37
Javascript Question

Javascript - fill in the textbox dynamically

Is it possible to fill textbox using javascript?
I have this code

<input type="text" id="output">

After using the script, I want to have selected value in textbox. I'm very new to javascript and I tried this

javascript: document.getElementById('output').innerHTML = "100";

However, it doesn't work as I expected. So after using the script I want HTML look like

<input type="text" id="output" value="100">

Is there any way to manage this? Thanks


You can use .value or .setAttribute.

document.getElementById('output').value = "100";


document.getElementById('output').setAttribute("value", "100");