PDA

View Full Version : pass control in a function



otnj2ee
Jun 4th, 2008, 02:56 AM
In a JSP,

<input id="contrlOne" value="" />

<input id="contrlTwo" value="" />

Normally I can do this:

<input id="contrlTwo" value="" onclick="test(this)" />

We know "this" represents "contrlTwo"


--What if I want to pass the control for "contrlOne", how can I do it?



Scott

GO ILLINI
Jun 4th, 2008, 04:35 AM
<input id="contrlTwo" value="" onclick="test(document.formname.contrlOne)" />

shyam
Jun 4th, 2008, 04:37 AM
since you've not the set the name the form method will not work in FF use document.getElementById instead


<input id="contrlTwo" value="" onclick="test(document.getElementById('contrlOne'))" />