views:

307

answers:

2

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;         
        }
    }

+3  A: 

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.

David Hedlund
+2  A: 

Try 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;
}
Canavar