473,671 Members | 2,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change HTML label on the fly

I want to change the label on the fly (when the user click the
checkbox), but my attempt
InputForm.lataL bl.value = "LATA * "; didn't work. Here's my code, any
ideas?
thanks !!!
<html>
<script type="text/javascript">
function ig_onchange()
{ if (InputForm.ig.c hecked == true)
{ InputForm.btn.v alue = "Populate";
InputForm.lataL bl.value = "LATA * "; //DOES NOT WORK!!!
}
else
{
InputForm.btn.v alue = "Validate";
}
}
</script>
<body>
<form name="InputForm ">
<P><input type="checkbox" name="ig" onclick="ig_onc hange()">
<P><label for="lataLbl">L ATA</label>
<P><input type="button" name="btn" value="Validate ">
</form>
</body>
</html>
Jul 23 '05 #1
3 26962
Voyez innerhtml

GR

Matt a écrit:
I want to change the label on the fly (when the user click the
checkbox), but my attempt
InputForm.lataL bl.value = "LATA * "; didn't work. Here's my code, any
ideas?
thanks !!!
<html>
<script type="text/javascript">
function ig_onchange()
{ if (InputForm.ig.c hecked == true)
{ InputForm.btn.v alue = "Populate";
InputForm.lataL bl.value = "LATA * "; //DOES NOT WORK!!!
}
else
{
InputForm.btn.v alue = "Validate";
}
}
</script>
<body>
<form name="InputForm ">
<P><input type="checkbox" name="ig" onclick="ig_onc hange()">
<P><label for="lataLbl">L ATA</label>
<P><input type="button" name="btn" value="Validate ">
</form>
</body>
</html>


Jul 23 '05 #2
jr********@hotm ail.com (Matt) writes:
I want to change the label on the fly (when the user click the
checkbox), but my attempt
InputForm.lataL bl.value = "LATA * "; didn't work.
No, for many reasons.

First of all, referring to the form by using its name as a variable
won't work in most browsers (it will work in IE).

The label is not a form control, so it's not a property of the form.

The content of a label is normal HTML, so you can't refer to it
as a simple property named "value".
Here's my code, any ideas?


Try this:
---
<!DOCTYPE html PUBLIC "-//W3C/HTML 4.01//EN">
<html>
<title>Title element is required, as is DOCTYPE!</title>
<script type="text/javascript">
function ig_onchange() {
var form = document.forms['InputForm'].elements;
if (form.ig.checke d) {
form.btn.value = "Populate";
document.getEle mentById("label Id").firstChild .nodeValue="LAT A *";
} else {
form.btn.value = "Validate";
}
}
</script>
<body>
<form name="InputForm " id="InputForm" >
<p><input type="checkbox" name="ig" onclick="ig_onc hange()"></p>
<p><label id="labelId" for="buttonId"> LATA</label></p>
<p><input type="button" id="buttonId" name="btn" value="Validate "></p>
</form>
</body>
</html>
---

It only works in modern browsers. There are a few older browser
(especially IE 4) that can be made to work with some extra code.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #3
Don't multi post. It annoys the regulars when found out.

I just read this in alt.html.

Cross post if you must.

Jeff
"Matt" <jr********@hot mail.com> wrote in message
news:ba******** *************** ***@posting.goo gle.com...
I want to change the label on the fly (when the user click the
checkbox), but my attempt
InputForm.lataL bl.value = "LATA * "; didn't work. Here's my code, any
ideas?
thanks !!!
<html>
<script type="text/javascript">
function ig_onchange()
{ if (InputForm.ig.c hecked == true)
{ InputForm.btn.v alue = "Populate";
InputForm.lataL bl.value = "LATA * "; file://DOES NOT WORK!!!
}
else
{
InputForm.btn.v alue = "Validate";
}
}
</script>
<body>
<form name="InputForm ">
<P><input type="checkbox" name="ig" onclick="ig_onc hange()">
<P><label for="lataLbl">L ATA</label>
<P><input type="button" name="btn" value="Validate ">
</form>
</body>
</html>

Jul 23 '05 #4

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

Similar topics

2
14397
by: knoak | last post by:
Hi there, In my form, after validation, labels of wrong fields are turned into a red color. What i want now is when you hit 'reset', to make all the labels grey again. I have the next code: ====================================== function GrayLabels()
0
1825
by: beanweed | last post by:
BACKGROUND ---------- I have an ASP.NET application having two panels. In one panel, an XML document, transformed using xsl, is displayed. In the other panel are some controls that allow a user to change the xml. For example, each "l_item" element appears as a row in a table labelled with a "label"; so if I have <l_item id="1"> <label>blah</label> ...
7
2086
by: David | last post by:
Hi, I'd really appreciate any help. Im trying to change a label over and over again. I can change it the first time, by using the following code, however it never works again, how can i do this so it uses the same element name? This is driving me insane. On the second call to var spanElm = document.getElementById("FirstNameLengthLabel"); spanElm is set to NULL. <script language=javascript>
18
24954
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin, that IE7 does not seem to offer any way to control the font size of a text input element.
10
3580
by: apparker | last post by:
I'm creating a new GUI for a program and it is for a medical exam. There are so many different things to ask someone during a history it wastes too much space to make checkboxes for everything so I had an idea: Can I simply create a list of conditions and when the doctor clicks them, they turn red? And clicking them again would make them default again? This would really make the exam better since the doctor could quickly glance at a...
0
1289
by: imranabdulaziz | last post by:
Hi all, I am using asp.net2.0 and C# VS2005. I am creating asp.net web server control templates Dynamically . My requirement is such that sp return very no of field( 4 or 5 or 6 …). Now I am assigning it to datalist by creating web server control template dynamilly. My problem is as no of field return very .how can I change databinding(which is method of itemplate) method so that I can bind data as per field. That is how can I change...
2
1771
RedSunFlowers32
by: RedSunFlowers32 | last post by:
Hi - I am creating a form for my personal business site. I want people to be able to get their own shipping total for the item(s) they have purchased. I have another code from a different file I want to use. I am unclear on which lines to remove to stop the pop-up windows from asking the user to input their information. Could someone please point this out to me? Thank you! Current code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
0
915
by: vincent90152900 | last post by:
I like to Customize the layout of a CreateUserWizard component and I would like to chnge the “Create User” button to an ImageButton. How to do that? Following is my codes. <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" OnCreatedUser="CreateUserWizard1_CreatedUser" Height="120px" Width="241px"> <WizardSteps> <asp:CreateUserWizardStep runat="server"> ...
0
8485
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
8828
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
8605
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,...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4227
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
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
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
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
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.