Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve Value from form object

Status
Not open for further replies.

LindaH

Programmer
Dec 12, 2001
42
US
I'm trying to pass a value for further processing using a form element, lblHiddenControl. This is a .NET server control, so there is no "name" attribute, just an "id." When I use the following code, I get the error message, "Object doesn't support this property or method."

if (window.document.getElementById("lblHiddenControl")) {
alert (document.frmProfile.getElementById("lblHiddenControl").value);
}


When I do a View Source, this is the HTML code I see for this object: <span id=&quot;lblHiddenControl&quot;>txtLogin</span>

How can I get the vlaue of this control?
 
I figured this one out. For future reference:

To retrieve a value from an <asp:label> control:
document.getElementById(&quot;lblHiddenControl&quot;).innerText

To retrieve a value from an <asp:textbox> control:
document.getElementById(&quot;txtHiddenControl&quot;).value

And to use that value:
if (window.document.getElementById(&quot;txtHiddenControl&quot;)) {
document.getElementById(document.getElementById(&quot;txtHiddenControl&quot;).value).scrollIntoView(true);
document.getElementById(document.getElementById(&quot;txtHiddenControl&quot;).value).focus();
}


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top