Setting values for a textbox in client javascript

  • Thread starter Thread starter Robert Storrs
  • Start date Start date
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
 
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)
 
Back
Top