By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,652 Members | 1,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,652 IT Pros & Developers. It's quick & easy.

Image visibility in IE

P: n/a
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>


Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> 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?
<input type="checkbox" name="requireName" onchange="javascript:
updateReq();" checked>Name Required


IE is not registering the onchange event for the checkbox. Onclick works
fine.

Jul 20 '05 #2

P: n/a
JW
onclick is what I needed....I must've had a brain fart there... thanks!

"Brett Merkey" <bm*****@tampabay.rr.com> wrote in message
news:Po*******************@twister.tampabay.rr.com ...
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?
<input type="checkbox" name="requireName" onchange="javascript:
updateReq();" checked>Name Required


IE is not registering the onchange event for the checkbox. Onclick works
fine.

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.