473,623 Members | 3,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Jul 20 '05 #1
2 30024


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/

Jul 20 '05 #2
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/

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
13141
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like this, with a flush left margin:
1
1577
by: John Smith | last post by:
I created a dataTable that returns a value from a stored procedure. How would I bind that results of a query to an <asp:label>? Thank you!
5
8303
by: Brian Foley | last post by:
Hello, I am used to using the label tag with check boxes and radio buttons in html forms. This allows me to click on the text of the label to activate/deactivate the check box / button, rather than having to click on the (possibly small) box or button. I recently tried to assign a label to a select "drop down list", but found that when I clicked on the label text to bring it into focus, the select box was reset to the first entry. ...
3
3806
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644" onclick="__doPostBack('SitesRadioButtonList_3','')" language="javascript" />
1
1881
by: Hongbo | last post by:
Hi, I have a mobile form: === <body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm"> <mobile:Form id=Form1 runat="server"> <mobile:label runat="server" id="lblT" /> </mobile:Form> </body> ===
0
1605
by: CharlesA | last post by:
Hi folks, I'm using ASP.net 1.1 with C# I've got this kind of thing going <div class="row"> <label class="col1">Rm Name</label> <asp:textbox id="txtRM" runat="server" cssclass="col2" ReadOnly="True" EnableViewState="False"></asp:textbox> <label class="col3">Rm Phone</label> <asp:textbox id="txtRmPhone" runat="server" cssclass="col4" ReadOnly="True"
7
1817
by: Smokey Grindle | last post by:
How can you correctly use the <labelelement in asp.net? does the label custom control corelate to this tag correctly in the same way in that if you click it it will select the tied element? thanks
3
2564
by: Homer J. Simpson | last post by:
I have the following stored procedure: ALTER PROCEDURE . AS BEGIN SET NOCOUNT ON; SELECT COUNT(*) FROM QUICKNOTES END ....and the following data source in my .aspx file:
3
2061
Dormilich
by: Dormilich | last post by:
Hi, I just have one thing about the label element, where I’m not certain. <label> is commonly used to attach visual/text information to a form control. so far, so good. <!-- just to make it visible --> <input type="checkbox" value="yes" id="mysql"> <label for="mysql">save MySQL</label> Now supposing I want to toggle the visibility of a <div> containing e.g. a description of something via JavaScript. although it is not exactly specified...
0
8221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8662
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8603
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4067
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2593
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1468
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.