Search code examples
javascripttextbox

Why is my element value not getting changed? Am I using the wrong function?


I have an asp.net mvc application and i am trying to assign value to my textbox dynamically, but it seems to be not working (I am only testing on IE right now). This is what I have right now..

document.getElementsByName('Tue').Value = tue; (by the way tue is a variable)

I have also tried this variation but it didnt work either.

document.getElementsById('Tue').Value = tue; (by the way tue is a variable)

Can someone where please tell me where I am going wrong with this?


Solution

  • It's document.getElementById, not document.getElementsByID

    I'm assuming you have <input id="Tue" ...> somewhere in your markup.