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.'