1

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..

Community
  • 1
  • 1
user754443
  • 47
  • 1
  • 7
  • 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 The GPT Wizard May 15 '11 at 12:19

2 Answers2

3

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

document.getElementById("musicstock1").value = "5";
Headshota
  • 21,021
  • 11
  • 61
  • 82
1

You want:

function insert () {
    document.getElementById('musicstock1').value = "5";
}
VoteyDisciple
  • 37,319
  • 5
  • 97
  • 97