Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

id and name

 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



what's the difference between "id" and "name" ? which one should be used when we access this element via using javascript ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The id attribute assignes an identifier to any element in the DOM for use in client-side scripting. The name attribute is applicable only to form elements and is used to assign the name for the submission parameter for that form element.

So, in short:
  • id is used in JavaScript on the client
  • name is used on the server to collect request parameters.


  • Older JavaScript used the names as part of client-side addressing, but that's antiquated and fragile and should no longer be done that way.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic