I'm using an <Input> of type image and calling an onlick funtion that validates data. Many <Input> tags call this validate function. Is there a way I can get the name of the <Input> tag that called the function? Thanks.
When you call the function - send the tag object to it:
<input type="image" name="img_1" onClick="validate(this)">
Then you just need to change the validate function to incorporate this information.
sample:
function validate(){
var name = (arguments[0])?arguments[0].name:null;
//...rest of validate functon
}
}
The reason I did this is so that the argument is optional, just in case you can't go back and change all the calls to it - or only sometimes you want to include the name.
Also it relies on the input having a (unique) name.
You may have to modify whatever is in the rest of the function to cope with the case where name =null, unless you are always going to send the object to the method.
Of course this entails modifying all the method calls, I don't think there is any Event.getSource() - not that I can find. ;-)
b2 - benbiddington@surf4nix.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.