1
votes

Please help, How to insert number into inputbox by Id.

<input name="table1" type="text" size="1" id="musicstock1"/>

Would like to insert for example number (5) into this particular input box when button clicked.

So push the "Insert" button number 5 show on inputbox

is this correct?

function insert () {
    document.getElementById('musicstock1').innerHTML = "5";
}

Thank you in advance

Appericiate for Replys... Please Check @

http://jsfiddle.net/JxfcH/#

Not Worked..

2
Please see my edit to learn how to format your code properly for the next time - regarding your question, you were using innerHTML instead of value. - Shadow Wizard Is Vaccinated V3

2 Answers

3
votes

you must assign value to the "value" attribute of the input box.

document.getElementById("musicstock1").value = "5";
1
votes

You want:

function insert () {
    document.getElementById('musicstock1').value = "5";
}