SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getElementById, only not

    Hi all,

    I have mutiple divs with the id's of "Page[var]". For example...

    .
    .
    .
    <div id="Page[page1]">Page 1</div>
    <div id="Page[page2]">Page 2</div>
    <div id="Page[page3]">Page 3</div>
    .
    .
    .

    Now, the text inside the [] will vary. I need to change the style all these Page[] div's at once.

    Something like,

    HTML Code:
    document.getElementById(Page[]).style.display='none';
    How do I do this?

    Thanks,
    David

  2. #2
    SitePoint Zealot johno's Avatar
    Join Date
    Sep 2003
    Location
    Bratislava, Slovakia
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, why dont you take one parent div contaning all pagedivs and then simply cycle trought all direct childs? (pagedivs) ?
    Annotations support for PHP5
    TC/OPT™ Group Leader

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    because after all of them are hidden, one will be changed to display-inline and a parent div would block that

  4. #4
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I really need is a way to modify all of the div's individually by recognizing their "Page[]" ID.

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any Suggestions?

  6. #6
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is Anyone Out There?

  7. #7
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, we're out here, just confused.

    Is PHP involved here? If so, there's certainly a better way to do this. You didn't mention a key detail: are the numbers ("Page[page1]", "Page[page2]", "Page[page3]") consecutive? If so:
    Code:
    var el, n = 1;
    while (el = document.getElementById('Page[page' + n + ']'))
             do something with el
    ::: certified wild guess :::


Bookmarks

Posting Permissions

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