This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes difference between getElementById and getElementByName? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "difference between getElementById and getElementByName?" Watch "difference between getElementById and getElementByName?" New topic
Author

difference between getElementById and getElementByName?

André Asantos
Ranch Hand

Joined: Nov 23, 2009
Posts: 234
JavaScript - Which are the difference between getElementById and getElementByName?

André AS


André AS
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There is no getElementByName. There is getElementsByName. Guessing typo there.

getElementById gets an element via an id. getElementsByName returns an Array of elements by their name.

Some horrible browsers will use name if it can not find an id for getElementById and those browsers should be uninstalled and bytes burnt to a crisp.

Eric
André Asantos
Ranch Hand

Joined: Nov 23, 2009
Posts: 234
anyway getElementById is more use than other right?

thanks,
André AS
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Please take the time to choose the correct forum for your posts. This forum is for questions on JSP. For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

André Asantos wrote:anyway getElementById is more use than other right?

In my opinion, yes.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Yes, identifying elements by id is much preferred unless you have a really good reason to need to use the name (which does not have to be unique).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: difference between getElementById and getElementByName?
 
Similar Threads
Run as AWT or SWT Application Eclipse Question
difference RAD & WSAD
JATO Vs JDOM
Javascript and Struts validator
Need usage help for getDocumentById