hide <label>

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

    hide <label>

    Hi,
    can you tell me how I can make a <label> hidden?
    I have hidden the field after the label:

    var M_Hide = isNS4?'hide':'h idden';
    var M_Show = isNS4?'show':'v isible';
    .....
    <label id="uid">UserID : </label>
    <input name="UserID" type="text" value="" size="20">
    <script language="Javas cript1.2" type="text/javascript1.2">
    var input = document.theFor m.UserID;
    if (input.style)
    input.style.vis ibility=M_Hide;
    </script>

    but I am not sure how to hide: <label id="uid">UserID : </label> since
    <label> does not have a "name" field.

    Thanks.


  • Martin Honnen

    #2
    Re: hide &lt;label&gt ;



    Xerxes wrote:[color=blue]
    > Hi,
    > can you tell me how I can make a <label> hidden?
    > I have hidden the field after the label:
    >
    > var M_Hide = isNS4?'hide':'h idden';
    > var M_Show = isNS4?'show':'v isible';
    > ....
    > <label id="uid">UserID : </label>
    > <input name="UserID" type="text" value="" size="20">
    > <script language="Javas cript1.2" type="text/javascript1.2">
    > var input = document.theFor m.UserID;
    > if (input.style)
    > input.style.vis ibility=M_Hide;
    > </script>
    >
    > but I am not sure how to hide: <label id="uid">UserID : </label> since
    > <label> does not have a "name" field.[/color]

    You should make the label contain the input
    <label id="uid">...<in put ...></label>
    to associate the <label> with the <input>, then use
    var label;
    if (document.all)
    label = document.all.ui d;
    else if (document.getEl ementById)
    label = document.getEle mentById('uid') ;
    if (label && label.style)
    label.style.vis ibility = 'hidden';
    Depending on what you want to achieve you might prefer
    label.style.dis play = 'none'
    which hides the <label> and frees the screen spays it occupied (content
    is reflown)
    --

    Martin Honnen


    Comment

    • Xerxes

      #3
      Re: hide &lt;label&gt ;

      Hi,
      thanks for the info. This is not quite working the way I want. I should
      have elaborated a bit more.
      I am trying to make an input field, and its label, visible or hidden
      depending on what radio button is clicked.
      The input field represents IP address and the radio buttons are DHCP and
      Static IP. If the user clicks on the Static IP button, I want the IP
      address input field become visible and if the user clicks on DHCP, I
      want the field, and its label, to disappear.

      What I had was this (couldn't make label disappear:)

      <tr>
      <td><h3>Address ing</h3>
      </td>
      <td><h4>DHCP <input name="NetAddres sing" type="radio" value="DHCP"
      checked
      onClick="if (this.checked)
      {
      if (this.form['Static IP Address'].style){
      this.form['Static IP
      Address'].style.visibili ty=M_Hide;
      }
      }
      else if (this.form['StaticIPAddres s'].style){
      this.form['Static IP Address'].style.visibili ty =
      M_Show;
      }">
      </h4>
      </td>
      <td><h4>Stati c IP
      <input name="NetAddres sing" type="radio" value="Static IP"
      onClick="if (this.checked)
      {
      if (this.form['Static IP Address'].style){
      this.form['Static IP
      Address'].style.visibili ty=M_Show;
      this.form['Static IP Address'].focus();
      }
      }
      else if (this.form['Static IP Address'].style){
      this.form['Static IP Address'].style.visibili ty =
      M_Hide;
      }">
      </h4>
      </td>
      <td><h4><label> IP Address: </label></h4>
      <td>
      <input name="Static IP Address" type="text" value="0.0.0.0"
      size="20">
      <script language="Javas cript1.2"
      type="text/javascript1.2">
      var input = document.netFor m['Static IP
      Address'];
      if (input.style)
      input.style.vis ibility=M_Hide;
      </script>
      </td>
      </tr>

      where:

      var isIE4 = document.all;
      var isNS4 = document.layers ;
      var isNS6 = document.getEle mentById && !document.all;

      var M_Hide = isNS4?'hide':'h idden';
      var M_Show = isNS4?'show':'v isible';

      Thanks.

      "Martin Honnen" <Martin.Honnen@ t-online.de> wrote in message
      news:3F0072BF.7 040003@t-online.de...[color=blue]
      >
      >
      > Xerxes wrote:[color=green]
      > > Hi,
      > > can you tell me how I can make a <label> hidden?
      > > I have hidden the field after the label:
      > >
      > > var M_Hide = isNS4?'hide':'h idden';
      > > var M_Show = isNS4?'show':'v isible';
      > > ....
      > > <label id="uid">UserID : </label>
      > > <input name="UserID" type="text" value="" size="20">
      > > <script language="Javas cript1.2" type="text/javascript1.2">
      > > var input = document.theFor m.UserID;
      > > if (input.style)
      > > input.style.vis ibility=M_Hide;
      > > </script>
      > >
      > > but I am not sure how to hide: <label id="uid">UserID : </label>[/color][/color]
      since[color=blue][color=green]
      > > <label> does not have a "name" field.[/color]
      >
      > You should make the label contain the input
      > <label id="uid">...<in put ...></label>
      > to associate the <label> with the <input>, then use
      > var label;
      > if (document.all)
      > label = document.all.ui d;
      > else if (document.getEl ementById)
      > label = document.getEle mentById('uid') ;
      > if (label && label.style)
      > label.style.vis ibility = 'hidden';
      > Depending on what you want to achieve you might prefer
      > label.style.dis play = 'none'
      > which hides the <label> and frees the screen spays it occupied[/color]
      (content[color=blue]
      > is reflown)
      > --
      >
      > Martin Honnen
      > http://JavaScript.FAQTs.com/
      >[/color]


      Comment

      Working...