I have a textbox that I want to change text property of it with javascript, but I can't do.
My sample code below, Can anyone say what is wrong? Thanks...
function openAdresYeni(p) {
document.getElementById('hdnAdresIndex').innerText = p;
}
}
I have a textbox that I want to change text property of it with javascript, but I can't do.
My sample code below, Can anyone say what is wrong? Thanks...
function openAdresYeni(p) {
document.getElementById('hdnAdresIndex').innerText = p;
}
}
Share
Improve this question
edited Dec 4, 2009 at 7:32
David Hedlund
130k33 gold badges204 silver badges223 bronze badges
asked Dec 4, 2009 at 7:29
maveramavera
3,2417 gold badges47 silver badges60 bronze badges
2 Answers
Reset to default 8Try this :
function openAdresYeni(p) {
document.getElementById('hdnAdresIndex').value = p;
}
NOTE : By the way if your hdnAdresIndex
is a server control, you should use control's ClientID property to get client side id :
function openAdresYeni(p) {
document.getElementById('<%= hdnAdresIndex.ClientID %>').value = p;
}
use value
instead of innerText
also, if you're not in asp.net mvc, the ID of the control is probably not what you expect. Look into the myTextBox.ClientID
property on the asp.net control.