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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference object by variable name

Status
Not open for further replies.

sventekkrishti

Technical User
Jan 24, 2003
18
0
0
GB
Hi,

Can someone please clarify for me whether the following is possible. Can i reference an object i.e. textbox on web page by a variable in javascript. Using the onchange event i am passing to my javascript function the name of the object. i.e. txtBox1 - can i then in my javascript function do the following and change the value ? :-

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
function ChangeValue(PassedName)
{
PassedName.value=&quot;NewValuesGoesHere&quot;
}

//-->
</SCRIPT>
 
yes it can be done. u can pass the object itself.
<input type=&quot;text&quot; onclick=&quot;ChangeValue(this)&quot;>
(or)
<input type=&quot;text&quot; onclick=&quot;ChangeValue(document.FormName.txtbx)&quot; name=&quot;txtbx&quot;>


Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top