Hide table/row

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John M

    Hide table/row

    I want to hide the first row in my table and if a user click on a show
    button than show it. If it is visible than user can hide it with click a
    hide button.
    In default I hide it with:

    <tr id="ds" style="display: none">

    but how can I make it visible or hide it dynamicaly?

    Is it possible to do it not with TR but with TABLE?

    Thanks!



  • Martin Honnen

    #2
    Re: Hide table/row



    John M wrote:
    [color=blue]
    > I want to hide the first row in my table and if a user click on a show
    > button than show it. If it is visible than user can hide it with click a
    > hide button.
    > In default I hide it with:
    >
    > <tr id="ds" style="display: none">
    >
    > but how can I make it visible or hide it dynamicaly?[/color]

    function hideElement (elementId) {
    var element;
    if (document.all)
    element = document.all[elementId];
    else if (document.getEl ementById)
    element = document.getEle mentById(elemen tId);
    if (element && element.style)
    element.style.d isplay = 'none';
    }
    function showElement (elementId) {
    var element;
    if (document.all)
    element = document.all[elementId];
    else if (document.getEl ementById)
    element = document.getEle mentById(elemen tId);
    if (element && element.style)
    element.style.d isplay = '';
    }

    Now you can call
    showElement('ds ');
    to show the table row.
    However as not all browsers support JavaScript and even some of those
    that do don't support toggling style.display it is better if you don't use
    <tr id="ds" style="display: none">
    to hide the row but rather do it with script e.g.
    <table>
    <tr id="ds">
    <td>...</td>
    ...
    </tr>
    ...
    </table>
    <script type="text/javascript">
    hideElement('ds ');
    </script>



    --

    Martin Honnen


    Comment

    • Louise Woodward

      #3
      Re: Hide table/row


      Can you use style.display with labels too or not as I am trying it and
      I keep getting label is null but if I use an input textbox then it works

      Thanks

      "Martin Honnen" <mahotrash@yaho o.de> wrote in message
      news:3f8ec45c$1 @olaf.komtel.ne t...[color=blue]
      >
      >
      > John M wrote:
      >[color=green]
      > > I want to hide the first row in my table and if a user click on a show
      > > button than show it. If it is visible than user can hide it with click a
      > > hide button.
      > > In default I hide it with:
      > >
      > > <tr id="ds" style="display: none">
      > >
      > > but how can I make it visible or hide it dynamicaly?[/color]
      >
      > function hideElement (elementId) {
      > var element;
      > if (document.all)
      > element = document.all[elementId];
      > else if (document.getEl ementById)
      > element = document.getEle mentById(elemen tId);
      > if (element && element.style)
      > element.style.d isplay = 'none';
      > }
      > function showElement (elementId) {
      > var element;
      > if (document.all)
      > element = document.all[elementId];
      > else if (document.getEl ementById)
      > element = document.getEle mentById(elemen tId);
      > if (element && element.style)
      > element.style.d isplay = '';
      > }
      >
      > Now you can call
      > showElement('ds ');
      > to show the table row.
      > However as not all browsers support JavaScript and even some of those
      > that do don't support toggling style.display it is better if you don't use
      > <tr id="ds" style="display: none">
      > to hide the row but rather do it with script e.g.
      > <table>
      > <tr id="ds">
      > <td>...</td>
      > ...
      > </tr>
      > ...
      > </table>
      > <script type="text/javascript">
      > hideElement('ds ');
      > </script>
      >
      >
      >
      > --
      >
      > Martin Honnen
      > http://JavaScript.FAQTs.com/
      >[/color]


      Comment

      Working...