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" <Ma***********@ t-online.de> wrote in message
news:3F******** ******@t-online.de...
Xerxes wrote: 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.
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
http://JavaScript.FAQTs.com/