[Javascript] Dollar function for name=
Terry Riegel
riegel at clearimageonline.com
Tue Jun 1 10:15:47 CDT 2010
I think my post may have been a bit premature, as a bit of googling found document.getElementsByName() which returns all elements with that name. In most of my work name="" are unique in the same way id="" is unique, so for me this function may be all I need...
function $name(n){
if (typeof n == 'object') {
return n;
} else {
return document.getElementsByName(n)[0];
}
}
Terry
On Jun 1, 2010, at 11:06 AM, Terry Riegel wrote:
> Hello All,
>
> Is there a method for finding a name="whatever" on a page similar to document.getElementById('whatever')?
>
> For example suppose I have this form...
>
>
> <form action="go.html" method="post">
> <input type="text" name="myname">
> <input type="text" name="mypass">
> <input type="submit" name="mysubmit" value="Login">
> </form>
>
>
> I would like to target name="myname" in a similar way that I can with getElementById()
>
> Even if it takes a fair bit of code to do it it would be nice to have a 'dollar' type function for this.
>
> When I use the term dollar function I am referring to the fairly ubiquitous convenience function for getElementById() found in the popular javascript library prototype.
>
> Thanks,
>
> Terry Riegel
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript
More information about the Javascript
mailing list