Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Location
    Florida
    Posts
    155
    Thanks
    16
    Thanked 2 Times in 2 Posts

    How to generate a table with unique ids?

    Hello there,

    I've been trying to figure out how to make a table, in this case it's a 50x50 table with each one having a different "title" tag here is the first one:

    <td style="background-color:#0000BA;"><a href="page#" title="1"><font color="#000000"><strong>&nbsp;</strong></font></td>
    <td style="background-color:#0000BA;"><a href="page#2" title="2"><font color="#000000"><strong>&nbsp;</strong></font></td>

    I'm not really sure how to do this, I am thinking it is possible with a while loop, but I don't know how to add the variables and limit the row and column count.

    Any help would be greatly appreciated!

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,461
    Thanks
    0
    Thanked 632 Times in 622 Posts
    1. There is no such thing as a font tag - there used to be but it was deleted from HTML in 1997. You should replace it with a span tag and attach CSS instead.

    2. You can't use numbers by themselves after a # in the href as the value after the # points to an id in the page and ids must start with a letter.

    3. To generate the code in a while loop you'd need to run the loop using PHP. As you have a fixed number of entries you want for each difection a for loop would work better than a while loop. See http://php.net/manual/en/control-structures.for.php
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Oct 2009
    Location
    Florida
    Posts
    155
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Ah I see. I just had the numbers in the link after the "#" just to clarify. Thank you for pointing out the font tag. For loops, am I looking for a nested loop?

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,461
    Thanks
    0
    Thanked 632 Times in 622 Posts
    Yes, the inner loop would create the td tags for the one row and the outer loop would create the tr tag for the row and then call the inner loop.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    The reaper (01-08-2013)


  •  

    Posting Permissions

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