myyoungfamily
05-08-2008, 05:22 PM
Hey guys,
I'm working on a simple javascript function for some checkboxes that I have in a form. If one is checked the other needs to be unchecked. Kind of like a radio button but I need these to be separate inputs. Using the code below, two will uncheck one but one will not uncheck two. What am I doing wrong?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function unCheck(Form, Name){
document.forms[Form].elements[Name].checked = false;
}
</script>
</head>
<body>
<form name="something">
<input type="checkbox" name="something1" value="1" onclick"javascript:unCheck(this.form.name, 'something2');" /> Something 1
<br />
<input type="checkbox" name="something2" value="1" onclick="javascript:unCheck(this.form.name, 'something1');" /> Something 2
</form>
</body>
</html>
I'm working on a simple javascript function for some checkboxes that I have in a form. If one is checked the other needs to be unchecked. Kind of like a radio button but I need these to be separate inputs. Using the code below, two will uncheck one but one will not uncheck two. What am I doing wrong?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function unCheck(Form, Name){
document.forms[Form].elements[Name].checked = false;
}
</script>
</head>
<body>
<form name="something">
<input type="checkbox" name="something1" value="1" onclick"javascript:unCheck(this.form.name, 'something2');" /> Something 1
<br />
<input type="checkbox" name="something2" value="1" onclick="javascript:unCheck(this.form.name, 'something1');" /> Something 2
</form>
</body>
</html>