<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test if box is checked</title>
<script type="text/javascript">
<!--
// global reference to form
var ff; // global
// short ref to form
function shortCut() { ff=document.myForm; }
// ----------
// test if box checked and enable corresponding button
function testChecked()
{ var i;
for(i=0;i<ff.pmcheckbox.length;i++)
{// looks at each checkbox to see if checked
if(ff.pmcheckbox[i].checked==true)
{// if checked, disable corresponding button using checkbox value as ref to button in form
ff[ff.pmcheckbox[i].value].disabled=false;
alert("Box "+ff.pmcheckbox[i].value+" is checked. Button enabled")
}
}
}
//
// -------------
//-->
</script>
<style type="text/css">
<!--
body { font-family:arial,helvetica,sans-serif; font-size:13px; color:#00F; font-weight:bold; }
input { margin-right:20px; }
#block1 { margin-bottom:20px; }
#block1 p { margin:5px; }
#myForm { margin:50px 0px 0px 50px; width:250px; }
-->
</style>
</head>
<body onload="shortCut()">
<form name="myForm" id="myForm">
<div id="block1">
<p class="a"><input type="checkbox" name="pmcheckbox" value="B1"><input type="button" value="Button" name="B1" disabled></p>
<p><input type="checkbox" name="pmcheckbox" value="B2"><input type="button" value="Button" name="B2" disabled></p>
<p><input type="checkbox" name="pmcheckbox" value="B3"><input type="button" value="Button" name="B3" disabled></p>
<p><input type="checkbox" name="pmcheckbox" value="B4"><input type="button" value="Button" name="B4" disabled></div>
<!-- end block1 -->
<p>
<input type="button" onclick="testChecked()" value="Click to test if checked" name="aaa"></p>
<p>Click browser refresh to start again</p>
</form>
<!-- end myForm -->
</body>
</html>
Bookmarks