SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast Roj2002's Avatar
    Join Date
    Jan 2002
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I access this element?

    I have the following structure (I left out the <td>and <tr>):
    Code:
    <html>
     <body>
      <table>
       <form>
        <table>
         here is some form stuff (text fields etc)
        </table>
         <div id="test" style="display:none">
          <table>
           some stuff here
          </table>
         </div>
        </table>
       </form>
      </table>
     </body>
    </html>
    I need to make the <div id="test"> visible, but I can't access it:

    Code:
     
    document.getElementById(test).style.display="inline";
    gives me an error saying that this is not an object.

    Is it possible to acces this div? if so, how?

    Michael

  2. #2
    SitePoint Member
    Join Date
    Feb 2003
    Location
    UK
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    document.getElementById('test').style.display="inline";

    You need quotes around it, if you used (test) that would be passing an argument not a value.

    Pete

  3. #3
    SitePoint Enthusiast Roj2002's Avatar
    Join Date
    Jan 2002
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hawk7
    Try this:

    document.getElementById('test').style.display="inline";

    You need quotes around it, if you used (test) that would be passing an argument not a value.

    Pete
    Nope, that's not the problem, same error as before...

    Michael

  4. #4
    SitePoint Enthusiast Roj2002's Avatar
    Join Date
    Jan 2002
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Roj2002
    Nope, that's not the problem, same error as before...

    Michael
    Problem solved, stupid typo, sorry!

    Michael

  5. #5
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    test should be a string....
    Code:
    document.getElementById("test").style.display="inline";
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  6. #6
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And you'de probably be better setting the display property to "block" rather than "inline" to make it visible.


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
  •