[Javascript] Javascript Digest, Vol 30, Issue 1

shashanka n shashankan.10 at gmail.com
Mon Jun 7 00:48:22 CDT 2010


I think document.getElementByName*("n") *would be the right way to do it, or
am i wrong?

On Tue, Jun 1, 2010 at 10:30 PM, <javascript-request at lists.evolt.org> wrote:

> Send Javascript mailing list submissions to
>        javascript at lists.evolt.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.evolt.org/mailman/listinfo/javascript
> or, via email, send a message with subject or body 'help' to
>        javascript-request at lists.evolt.org
>
> You can reach the person managing the list at
>        javascript-owner at lists.evolt.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Javascript digest..."
>
> Today's Topics:
>
>   1.  Dollar function for name= (Terry Riegel)
>   2. Re: Dollar function for name= (Terry Riegel)
>   3. Re: Dollar function for name= (Rees, Mark)
>   4. Re: Dollar function for name= (Peter Brunone)
>   5. Re: Dollar function for name= (Terry Riegel)
>
>
> ---------- Forwarded message ----------
> From: Terry Riegel <riegel at clearimageonline.com>
> To: JavaScript List <javascript at lists.evolt.org>
> Date: Tue, 1 Jun 2010 11:06:42 -0400
> Subject: [Javascript] Dollar function for name=
> 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
>
>
> ---------- Forwarded message ----------
> From: Terry Riegel <riegel at clearimageonline.com>
> To: JavaScript List <javascript at lists.evolt.org>
> Date: Tue, 1 Jun 2010 11:15:47 -0400
> Subject: Re: [Javascript] Dollar function for name=
> 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
>
>
>
>
> ---------- Forwarded message ----------
> From: "Rees, Mark" <Mark.Rees at astrazeneca.com>
> To: "JavaScript List" <javascript at lists.evolt.org>
> Date: Tue, 1 Jun 2010 16:16:44 +0100
> Subject: Re: [Javascript] Dollar function for name=
> 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
>
> --------------------------------
> There is in prototype. See the docs, always a good starting point
>
> http://api.prototypejs.org/language/dollardollar/
>
> And use the CSS3 attribute selectors
>
> http://www.css3.info/preview/attribute-selectors/
>
> Obviously, the double dollar method returns an array of Elements rather
> than an Element, as attribute name/value pairs are not guaranteed to be
> unique. IDs of course are unique (in a valid document anyway)
>
> --------------------------------------------------------------------------
> AstraZeneca UK Limited is a company incorporated in England and Wales with
> registered number: 03674842 and a registered office at 15 Stanhope Gate,
> London W1K 1LN.
> Confidentiality Notice: This message is private and may contain
> confidential, proprietary and legally privileged information. If you have
> received this message in error, please notify us and remove it from your
> system and note that you must not copy, distribute or take any action in
> reliance on it. Any unauthorised use or disclosure of the contents of this
> message is not permitted and may be unlawful.
> Disclaimer: Email messages may be subject to delays, interception,
> non-delivery and unauthorised alterations. Therefore, information expressed
> in this message is not given or endorsed by AstraZeneca UK Limited unless
> otherwise notified by an authorised representative independent of this
> message. No contractual relationship is created by this message by any
> person unless specifically indicated by agreement in writing other than
> email.
> Monitoring: AstraZeneca UK Limited may monitor email traffic data and
> content for the purposes of the prevention and detection of crime, ensuring
> the security of our computer systems and checking Compliance with our Code
> of Conduct and Policies.
>
>
>
> ---------- Forwarded message ----------
> From: "Peter Brunone" <peter at brunone.com>
> To: "JavaScript List" <javascript at lists.evolt.org>
> Date: Tue, 1 Jun 2010 08:16:21 -0700
> Subject: Re: [Javascript] Dollar function for name=
> You mean document.getElementsByName?
>
> ----------------------------------------
>  From: "Terry Riegel" <riegel at clearimageonline.com>
> Sent: Tuesday, June 01, 2010 10:07 AM
> To: "JavaScript List" <javascript at lists.evolt.org>
> Subject: [Javascript] Dollar function for name=
>
> 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
>
>
>
> ---------- Forwarded message ----------
> From: Terry Riegel <riegel at clearimageonline.com>
> To: JavaScript List <javascript at lists.evolt.org>
> Date: Tue, 1 Jun 2010 12:55:22 -0400
> Subject: Re: [Javascript] Dollar function for name=
> > You mean document.getElementsByName?
>
> Yes, Thank you.
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript
>



-- 
Warm regards,

Shashanka N,

Software Developer, Asclepius Consulting & Technologies

9663817109 | shashanka.n at live.com |


More information about the Javascript mailing list