INPUT, name and id

liunx

Guest
Can I have different name and id attributes on the same input element like:<br />
<br />
<br />
<input name="name" id="first" /><br />
<br />
<br />
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.<!--content-->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<br />
<br />
<!-- m --><a class="postlink" href="http://www.w3.org/TR/html4/interact/forms.html#control-name">http://www.w3.org/TR/html4/interact/for ... ntrol-name</a><!-- m --><!--content-->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.<!--content-->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.<br />
<br />
Although it is perfectly legal to have the same name occurring for different input elements.<!--content-->So are you saying that if I name the form, it will the send the checkbox values with it's name?<!--content-->Originally posted by Rick Bull <br />
So it should be alright to use different IDs and NAMEs? <br />
<br />
For <input> yes<!--content-->Thanks for the help guys. Now I can finish my PHP guestbook :D<!--content-->
 
Back
Top