Results 1 to 2 of 2

Thread: getElementById and multiple tags...

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    getElementById and multiple tags...

    Lets say I have 2 or more elements with the ID "total". I am passing the index of the one I want to a function. I thought I could say:

    document.getElementById('total')[index].innerText = "Whatever";

    by that doesn't work. Is there a way I can do this?

    Thanks
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Uhm, no. ID is meant to be a unique ID.

    You can crawl through the document (so to speak) and grab the element you want if you know where it is. But getElementById will have unpredictable results.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

Posting Permissions

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



Click Here to Expand Forum to Full Width