Setting values for a textbox in client javascript

R

Robert Storrs

I need to set the value of a asp text box in javascript.

<asp:TextBox id="txtUserValue" runat="server"
test</asp:TextBox>

I have tied:

function setValue(valueData) {
alert(valueData);

document.Analysis_UserEnt.txtUserValue.Value = valueData;

document.Analysis_UserEnt.txtUserValue.Text = valueData;

document.Analysis_UserEnt.txtUserValue.InnerText =
valueData;

None of these work. Any suggestions? The function
setValue is being called by a child page. This works as I
have used alert statements to track progress.

Analysis_UserEnt is the asp form id

Bob Storrs
 
B

bruce barker

javascript is case sensitive you need to get it right

you options are:

document.Analysis_UserEnt.txtUserValue.value = valueData;
document.forms['Analysis_UserEnt'].txtUserValue.value = valueData;
document.getElementById('txtUserValue').value = valueData;

there is no .Text or .text property for an input box.

as the value of a text box is an attribute,

document.getElementById('txtUserValue').innerText
document.getElementById('txtUserValue').innerHTML

will return "", no matter what the value is.


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top