+ Post New Thread
Results 1 to 4 of 4
Web Development Thread, Append count() to Div/class in Coding and Web Development; I have some HTML: <div class="header">School Logo</div> <div class="content"> some text </div> <div class="header">School Logo</div> <div class="content"> some text </div> ...
  1. #1

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    29

    Append count() to Div/class

    I have some HTML:

    <div class="header">School Logo</div>
    <div class="content">
    some text
    </div>

    <div class="header">School Logo</div>
    <div class="content">
    some text
    </div>

    It repeats through the webpage putting a header div in to show the school logo. This is basically a very simple way of printing letter heads with content generated inside each "content" div.

    What I want to be able to do is print the First occurance of "header" but when multiple occurances of "header" are on the page I want it to ignore them all but the first one.

    What i would like to do is to add some javascript which will add a count to the div,

    <div class="header COUNT1">School Logo</div>
    <div class="content">
    some text
    </div>

    <div class="header COUNT2">School Logo</div>
    <div class="content">
    some text
    </div>

    And when the COUNT > 1 make "Header" invisible:

    .header {
    display: none; (Or similar)
    }

    Can anyone help?

  2. #2
    kesomir's Avatar
    Join Date
    Mar 2008
    Location
    London
    Posts
    286
    Thank Post
    14
    Thanked 28 Times in 23 Posts
    Rep Power
    17
    Why can't you just output one such div?

    What are you using to create the multiple divs?

  3. #3

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    29
    The webpage is create like so:

    Header

    ----

    Content (This html here is generated dynamically whereas header is hard coded)

    --

    Footer

    But each letter calls the Header when it gets generated so you end up with multiple headers on a single page.

    Trouble is the header html does not get parsed so i cant do anything dynamic there, E.g generate a count based on how many letters are to be printed and only print the header based on that number.

    Would it be possible to count the number of 'Header's put them into an array with a count and output that value back to the class on page load?

  4. #4

    Join Date
    Jan 2007
    Location
    Lowestoft, Suffolk
    Posts
    84
    Thank Post
    6
    Thanked 4 Times in 4 Posts
    Rep Power
    15
    Do you use a separate CSS file for printing?

    I'd add a second class for the all the headers that you don't want printed.

    <div class="header">School Logo</div>
    <div class="content">
    some text
    </div>

    <div class="header noprint">School Logo</div>
    <div class="content">
    some text
    </div>
    <div class="header noprint">School Logo</div>
    <div class="content">
    some text
    </div>

    Then in the CSS for printer...

    .noprint {
    display:none;
    }

    That's how I hide any items from the screen that I don't want printed.

    I'm not sure if you can do this though, can you give us more information on how the page is generated?
    Last edited by PaulBM; 1st September 2008 at 04:57 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 1
    Last Post: 4th June 2008, 11:03 AM
  2. Replies: 2
    Last Post: 1st February 2008, 10:24 AM
  3. Can Edugeek Count?
    By FN-GM in forum General Chat
    Replies: 9
    Last Post: 26th July 2007, 10:59 PM
  4. Class Server Authentication and Class Sites
    By dagza in forum Virtual Learning Platforms
    Replies: 2
    Last Post: 15th November 2006, 12:05 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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