www.webdeveloper.com
Results 1 to 7 of 7

Thread: INPUT, name and id

  1. #1
    Join Date
    Nov 2002
    Location
    England
    Posts
    275

    INPUT, name and id

    Can I have different name and id attributes on the same input element like:

    Code:
    <input name="name" id="first" />
    I thought that the HTML 4.01 specs said they must be identical, but when I (quickly) checked I could only find that rule for anchors.

  2. #2
    Join Date
    Nov 2002
    Posts
    984
    I think the difference here is that name for <a> (and some other tags) has the same function as ID, while name for <input> is a form control name

    http://www.w3.org/TR/html4/interact/...l#control-name

  3. #3
    Join Date
    Nov 2002
    Location
    England
    Posts
    275
    So it should be alright to use different IDs and NAMEs? I wanted them to be different because I have two checkboxes (so need the same name), but I wanted different IDs so I can associate a label with them each.

  4. #4
    Join Date
    Nov 2002
    Location
    XYZZY - UK
    Posts
    1,760
    I'd say typically you'd name the form containing the checkboxes; rather than each box, and then give each checkbox a unique id, or name.

    Although it is perfectly legal to have the same name occurring for different input elements.
    Last edited by Robert Wellock; 12-12-2002 at 11:46 AM.

  5. #5
    Join Date
    Nov 2002
    Location
    England
    Posts
    275
    So are you saying that if I name the form, it will the send the checkbox values with it's name?

  6. #6
    Join Date
    Nov 2002
    Posts
    984
    Originally posted by Rick Bull
    So it should be alright to use different IDs and NAMEs?
    For <input> yes

  7. #7
    Join Date
    Nov 2002
    Location
    England
    Posts
    275
    Thanks for the help guys. Now I can finish my PHP guestbook

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles