Click to See Complete Forum and Search --> : INPUT, name and id
Rick Bull
12-12-2002, 09:03 AM
Can I have different name and id attributes on the same input element like:
<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.
Stefan
12-12-2002, 09:35 AM
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/forms.html#control-name
Rick Bull
12-12-2002, 09:41 AM
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.
Robert Wellock
12-12-2002, 10:37 AM
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.
Rick Bull
12-12-2002, 12:02 PM
So are you saying that if I name the form, it will the send the checkbox values with it's name?
Stefan
12-12-2002, 02:00 PM
Originally posted by Rick Bull
So it should be alright to use different IDs and NAMEs?
For <input> yes
Rick Bull
12-12-2002, 05:32 PM
Thanks for the help guys. Now I can finish my PHP guestbook :D