PDA

View Full Version : Javascript onclick not working in IE



rjaskelton
01-25-2011, 05:09 PM
Hey everyone,
I am having troubles with my form not working correctly in IE. I have onclicks for different parts of my site. I am trying to use onclick and divs to make this happen. Can some look at my code and help me out?
Thanks/


<script type="text/javascript">
function switchFS(obj) {
var fset,i,fsclass;
fset=document.getElementsByTagName('fieldset');
fsclass = obj;
for ( i=0; i<fset.length; i++) {
if ((fset[i].getAttribute('class') != "user") && (fset[i].getAttribute('class') != fsclass)) {
fset[i].style.display = "none";
} else {
fset[i].style.display = "block";
}
}
}
</script>


</head>

<body id="submitform">
<div id="container">
<div id="header">
<?php include($dirprefix . "external/include/header.html"); ?>
</div><!-- end header -->
<div id="maincontent">
<h3>&nbsp;</h3>
<?php include($dirprefix . "external/include/menu_inactive.html"); ?>

<div id="bodycontent">
<div id="bodyleftcol">
<h4>Contact</h4>
<h5>Registration</h5>
</div>
<div id="bodyrightcol">
<h1 class="formhead">Site Registration</h1>
<p>Please register if you are a Zimmer customer, or an agency or designer working on behalf of one. Completing the requested information will enable us to continue to update and improve site content. Please make note of your password for future reference. You will receive an email with your login information.</p>
<div id="mainrightcol">
<form name="form" id="register" method="post" action="processregister.php">

<fieldset class="user">
<legend>i am a:</legend>
<label><input type="radio" value="Healthcare provider" class="checkbox" name="usertype" onclick="switchFS('healthcare');" /> Healthcare provider</label>
<label><input type="radio" value="Agency or designer for a customer" class="checkbox" name="usertype" onclick="switchFS('agency');" /> Agency or designer for a customer</label>
<label><input type="radio" value="Independent agency or designer" class="checkbox" name="usertype" onclick="switchFS('agency');" /> Independent agency or designer</label>
<label><input type="radio" value="Zimmer employee" class="checkbox" name="usertype" onclick="switchFS('zimmer');" /> Zimmer employee</label>
<label><input type="radio" value="Zimmer field representative" class="checkbox" name="usertype" onclick="switchFS('zimmer1');" /> Zimmer field representative</label>
<label><input type="radio" value="Media" class="checkbox" name="usertype" onclick="switchFS('user');" /> Media</label>
<label><input type="radio" value="Healthcare Author/Publisher" class="checkbox" name="usertype" onclick="switchFS('author');" /> Healthcare Author/Publisher</label>
<label><input type="radio" value="Other" class="checkbox" name="usertype" onclick="switchFS('user');" /> Other</label>
</fieldset>

<fieldset class="zimmer" style="display: none;">
<legend>zimmer information</legend>
<!--<label for="businessunit">Zimmer business unit: <input type="text" name="businessunit" value="" required="required" /></label>-->
<label for="division">Zimmer business unit:
<select name="division">
<option value="">- n/a -</option>
<option value="Knees">Knees</option>
<option value="Hips">Hips</option>
<option value="Extremities">Extremities</option>
<option value="Trauma">Trauma</option>
</select></label>
</fieldset>

<fieldset class="zimmer1" style="display: none;">
<legend>zimmer information</legend>
<!--<label for="businessunit">Zimmer business unit: <input type="text" name="businessunit" value="" required="required" /></label>-->
<label for="distributorship">Zimmer distributorship:
<input type="text" name="distributorship" value="" required="required" /></label>
</fieldset>


I have added the javascript and the section of code where the user picks how they are. Once you click on one of the users in IE the form goes away.

gusblake
01-25-2011, 06:32 PM
IE6 definitely has problems with getAttribute.

if ((fset[i].className != "user") && (fset[i].className != fsclass)) should work.