www.webdeveloper.com
Results 1 to 4 of 4

Thread: Handling Orphan <tr> Tags

  1. #1
    Join Date
    Feb 2009
    Posts
    102

    Handling Orphan <tr> Tags

    In a script I am working on (using php and javascript) I have php dynamically generate several pieces of a form (which is formatted using a table), and put them into a hidden div for Javascript to grab as the user builds a custom form that will be used to search a database.

    Each piece of the form will be a new row in a table, so I have them listed like so:
    HTML Code:
    <tr id="item1">
     <td>...</td><td...</td>
    </tr>
    <tr id="item2">
     <td>...</td><td...</td>
    </tr>
    <tr id="item3">
     <td>...</td><td...</td>
    </tr>
    Unfortunately, since those pieces are not currently in a table, they don't seem to show up in the DOM, and I'm having trouble accessing them in Javascript in order to clone them (using document.getElementById("item1")).

    Anyone have any ideas of what I'm doing wrong?

  2. #2
    Join Date
    Feb 2009
    Location
    Michigan, US
    Posts
    21
    Having you tried to assign an ID to the table, which must be unique. If the "name" is unique, you can use it for the ID and name. Then try:

    <table id='IDofmytable'>

  3. #3
    Join Date
    Feb 2009
    Posts
    102
    That's the problem. The <TR>'s I need to access are not in a table... And there are also several divs mixed in, so it didn't work when I tried wrapping the whole section in a table either.

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Create a valid table and you'll have no problems.
    At least 98% of internet users' DNA is identical to that of chimpanzees

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
  •  
HTML5 Development Center



Recent Articles