/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] JS id / name question

I know that the ID argument needs to be unique.
I also know that the NAME argument may be duplicated,
as in a radio button as a special case.

What I would like to know is this:

  • 1.

    Are there any drawbacks to using the ID and NAME as the same
    (spelling and upper-/lower-case) except in the special RBtn cases?

    Is this a poor or acceptable practice or does it depend upon the application?

  • 2.

    If I’m not sending any information with a submit event in a form,
    do I even need to use the ‘NAME’ argument if I reference my elements
    with the ‘getElementById()’ method?

  • 3.

    Can I put a unique ID for each of the radio button options and
    determine the value or option of each radio button without referrencing
    each of the options[] in the RBtn array?

  • Answers to any or all of the above are much appreciated.

    to post a comment
    JavaScript

    4 Comments(s)

    Copy linkTweet thisAlerts:
    @mrhooApr 12.2008 — You only [B]need [/B]a name for fields that will be uploaded to a server.

    You only [B]need [/B]an id to 'attach' a label to its element with an htmlFor.

    It is not an error to have both name and id attributes in html, but it is in xml.

    Using fieldsets and labels (with ids and not names) is a good way to organize fields in a complex form.
    Copy linkTweet thisAlerts:
    @JMRKERauthorApr 13.2008 — Thank you 'mrhoo'

    One further clarification:
    It is not an error to have both name and id attributes in html, but it is in xml.[/QUOTE]

    When I do have both name and id in HTML tag,

    can or should they be the different or same,

    or is this considered poor scripting?

    Or does it just not matter?

    Thanks again!
    Copy linkTweet thisAlerts:
    @mrhooApr 13.2008 — This is a good article about html forms and the dom-

    http://www.websemantics.co.uk/tutorials/accessible_forms/
    Copy linkTweet thisAlerts:
    @JMRKERauthorApr 13.2008 — Thanks again.

    Helpful article.
    ×

    Success!

    Help @JMRKER 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 4.29,
    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: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

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

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...