J
Justin Wright
Greetings -
I am trying to set up a page where there are a couple of checkboxes, and
based on the selected checkbox, certain input fields are required. For the
required fields, I want to display a red asterick as an image (
required.jpg ) next to the field iteslf. Thus, I am trying to write a
JavaScript function that will get called via the "onchange" action for each
checkbox.... this function willl either set the visibility to "visible" or
"hidden" for the red asterick ( required.jpg ) next to each input ( name,
address, email, etc... ). I am able to get this working in Netscape (
7.02 ), however I can't seem to get it to work for Internet Explorer (
6.02 ).
Here is a trimmed down, working ( at least in Netscape ) sample of what I am
trying to do. Any idea on what I need to do differently to get this to work
in IE?
Any help is appreciated. Thanks,
Jusitn
---------------------------------------------------------------------
<html>
<head>
<title>Test</title>
<script language="JavaScript">
<!--
function updateReq( ) {
if( document.testForm.requireName.checked ) {
document.images.req_Name.style.visibility = "visible";
} else {
document.images.req_Name.style.visibility = "hidden";
}
}
//-->
</script>
</head>
<body>
<form name="testForm">
<input type="checkbox" name="requireName" onchange="javascript:
updateReq();" checked>Name Required
<br>
<img name="req_Name" id="req_Name"
src="includes/images/required.jpg">Name:<input name="Name" type="text"
size=25 maxlength=50>
</form>
</body>
</html>
I am trying to set up a page where there are a couple of checkboxes, and
based on the selected checkbox, certain input fields are required. For the
required fields, I want to display a red asterick as an image (
required.jpg ) next to the field iteslf. Thus, I am trying to write a
JavaScript function that will get called via the "onchange" action for each
checkbox.... this function willl either set the visibility to "visible" or
"hidden" for the red asterick ( required.jpg ) next to each input ( name,
address, email, etc... ). I am able to get this working in Netscape (
7.02 ), however I can't seem to get it to work for Internet Explorer (
6.02 ).
Here is a trimmed down, working ( at least in Netscape ) sample of what I am
trying to do. Any idea on what I need to do differently to get this to work
in IE?
Any help is appreciated. Thanks,
Jusitn
---------------------------------------------------------------------
<html>
<head>
<title>Test</title>
<script language="JavaScript">
<!--
function updateReq( ) {
if( document.testForm.requireName.checked ) {
document.images.req_Name.style.visibility = "visible";
} else {
document.images.req_Name.style.visibility = "hidden";
}
}
//-->
</script>
</head>
<body>
<form name="testForm">
<input type="checkbox" name="requireName" onchange="javascript:
updateReq();" checked>Name Required
<br>
<img name="req_Name" id="req_Name"
src="includes/images/required.jpg">Name:<input name="Name" type="text"
size=25 maxlength=50>
</form>
</body>
</html>