dougcranston
Technical User
I am trying to create a function that can be called from a form to ensure only appropriate checkboxes are selected.
I can create "hard coded" code for each grouping but with at present 30 groupings with the potential of more, that is neither smart nor prudent.
I have checked the books I have, searched this site, and the web and nothing has seemed to answer my problem.
Although I am sure DOM is the appropriate approach, I am stumped on how to proceed. I have been remiss in becoming more proficient with utilizing the DOM but I am no where close to what I need, and as with many of the posts here, I have an imposed deadline..
So any suggestions, or possibly a site with a snippet that might shed light on this would be greatly appreciated.
I have placed a small portion of the code, and some pseudo code on what I think needs to happen, but I am open to suggestions. My thought would be to trigger the function calls using the onClick event.. Atleast that was how I envisioned doing it.
Thanks alot in advance.
Doug Cranston..
----- code follows ------
<head>
<script language="JavaScript"><!--
function checkSkillShare(skl,shr,trn) {
Pseudo code..
If skl is checked and/or shr is checked
then uncheck trn
}
function checkTrain(skl,shr,trn) {
Pseudo code..
If trn is checked
then uncheck skl AND shr
}
//--></script>
</head>
<body>
<form name="myForm">
<!-- this is a start if a chkbox grouping -->
<input type="checkBox" id="PCskl" name="PCskl" onClick="checkSkillShare(PCskl,PCshr,PCtrn)">PC Skilled
<input type="checkBox" id="PCshr" name="PCshr" onClick="checkSkillShare(PCskl,PCshr,PCtrn)">PC Willing to Share
<input type="checkBox" id="PCtrn" name="PCtrn" onClick="checkTrain(PCskl,PCshr,PCtrn)">PC Needs Training<br>
<!-- this is then end of a grouping -->
<!-- this is a start if a chkbox grouping -->
<input type="checkBox" id="Accessskl" name="Accessskl" onClick="checkSkillShare(Accessskl,Accessshr,Accesstrn)">Access Skilled
<input type="checkBox" id="Accessshr" name="Accessshr" onClick="checkSkillShare(Accessskl,Accessshr,Accesstrn)">Access Willing to Share
<input type="checkBox" id="Accesstrn" name="Accesstrn" onClick="checkTrain(Accessskl,Accessshr,Accesstrn)">Access Needs Training<br>
<!-- this is then end of a grouping -->
</form>
</body>
I can create "hard coded" code for each grouping but with at present 30 groupings with the potential of more, that is neither smart nor prudent.
I have checked the books I have, searched this site, and the web and nothing has seemed to answer my problem.
Although I am sure DOM is the appropriate approach, I am stumped on how to proceed. I have been remiss in becoming more proficient with utilizing the DOM but I am no where close to what I need, and as with many of the posts here, I have an imposed deadline..
So any suggestions, or possibly a site with a snippet that might shed light on this would be greatly appreciated.
I have placed a small portion of the code, and some pseudo code on what I think needs to happen, but I am open to suggestions. My thought would be to trigger the function calls using the onClick event.. Atleast that was how I envisioned doing it.
Thanks alot in advance.
Doug Cranston..
----- code follows ------
<head>
<script language="JavaScript"><!--
function checkSkillShare(skl,shr,trn) {
Pseudo code..
If skl is checked and/or shr is checked
then uncheck trn
}
function checkTrain(skl,shr,trn) {
Pseudo code..
If trn is checked
then uncheck skl AND shr
}
//--></script>
</head>
<body>
<form name="myForm">
<!-- this is a start if a chkbox grouping -->
<input type="checkBox" id="PCskl" name="PCskl" onClick="checkSkillShare(PCskl,PCshr,PCtrn)">PC Skilled
<input type="checkBox" id="PCshr" name="PCshr" onClick="checkSkillShare(PCskl,PCshr,PCtrn)">PC Willing to Share
<input type="checkBox" id="PCtrn" name="PCtrn" onClick="checkTrain(PCskl,PCshr,PCtrn)">PC Needs Training<br>
<!-- this is then end of a grouping -->
<!-- this is a start if a chkbox grouping -->
<input type="checkBox" id="Accessskl" name="Accessskl" onClick="checkSkillShare(Accessskl,Accessshr,Accesstrn)">Access Skilled
<input type="checkBox" id="Accessshr" name="Accessshr" onClick="checkSkillShare(Accessskl,Accessshr,Accesstrn)">Access Willing to Share
<input type="checkBox" id="Accesstrn" name="Accesstrn" onClick="checkTrain(Accessskl,Accessshr,Accesstrn)">Access Needs Training<br>
<!-- this is then end of a grouping -->
</form>
</body>