/    Sign up×
Community /Pin to ProfileBookmark

INPUT, name and id

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

[code]
<input name=”name” id=”first” />
[/code]

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.

to post a comment
HTML

6 Comments(s)

Copy linkTweet thisAlerts:
@StefanDec 12.2002 — 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
Copy linkTweet thisAlerts:
@Rick_BullauthorDec 12.2002 — 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.
Copy linkTweet thisAlerts:
@Robert_WellockDec 12.2002 — 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.
Copy linkTweet thisAlerts:
@Rick_BullauthorDec 12.2002 — So are you saying that if I name the form, it will the send the checkbox values with it's name?
Copy linkTweet thisAlerts:
@StefanDec 12.2002 — [i]Originally posted by Rick Bull [/i]

[B]So it should be alright to use different IDs and NAMEs?[/B][/QUOTE]


For <input> yes
Copy linkTweet thisAlerts:
@Rick_BullauthorDec 12.2002 — Thanks for the help guys. Now I can finish my PHP guestbook ?
×

Success!

Help @Rick_Bull spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...