php and javascript question.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #16
    :) there is another method that will retrieve all HTML elements that match a specific HTML tag.

    This method is called document.getEle mentsByTagName.

    Or you could pass the ID of the table into the JavaScript function.
    In that case your JavaScript function would take a parameter: tableID (which is a string containing the ID of the table that you want to hide or display)

    For example your JavaScript method would have to be modified to:
    Code:
     function HideDisplayTable(tableID){
      var tableElement= document.getElementById(tableID);
      //.......
    }
    And your buttons would look like:
    Code:
    <button onclick="displayRow('table1');" >Show table1</button>
    <button onclick="displayRow('table2');" >Show table2</button>
    The thing is that you're going to have to figure out whether or not to display the particular table that the function is managing (just check if it's display style is 'none'...if so change it to 'table'...if not change it to 'none').

    Code:
     function HideDisplayTable(tableID){
      var tableElement= document.getElementById(tableID);
      if(tableElement)
      { var hideTable = true;
        if(tableElement.style.display == 'none')
        { hideTable = false;}
      //.................
    }
    :)

    -Frinny

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #17
      Originally posted by yeshello54
      Oh just thought of something...
      Code:
      document.getElementById("table");
      does this code take multiple parameters so that I could do
      Code:
      var getelement = document.getElementByid("table1",table2","table3")
      or will i have to set a new variable for each button i make to close each table. so will i need to do this
      Code:
      var getelement1=document.getElementByid("table1")
      var getelement2=document.getElementByid("table2")
      etc....
      The second way. If in doubt, check the documentation (MSDN, MDC - take your pick).

      Comment

      Working...