3

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

2 Answers 2

8

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;
}
Sign up to request clarification or add additional context in comments.

Comments

6

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.