Disable resten af Checkboxe når der er valgt 2
Hej jeg har denne kode:<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td valign=top class=formtext><em>Select up to 2 spots</em><br>
<br></td>
</tr>
<tr>
<td valign=top class=formtext width="150" align="right" style="padding-top: 3px;"><b>Apology:</b></td>
<td class=formtext style="padding-left: 10px;"><input class=formtext type=checkbox name=txtCreative value="Apology: 30 seconds" onClick="BoxClicked(); GetGroup();">
30 seconds</td>
</tr>
<tr>
<td valign=top class=formtext width="150" align="right" style="padding-top: 3px;"><b>Monkeys:</b></td>
<td class=formtext style="padding-left: 10px;"><input class=formtext type=checkbox name=txtCreative value="Monkeys: 30 seconds" onClick="BoxClicked(); GetGroup();">
30 seconds</td>
<td class=formtext style="padding-left: 10px;"><input class=formtext type=checkbox name=txtCreative value="Monkeys: 30 25/05" onClick="BoxClicked(); GetGroup();">
:25/:05</td>
</tr>
<tr>
<td valign=top class=formtext width="150" align="right" style="padding-top: 3px;"><b>Whoopee Cushion:</b></td>
<td class=formtext style="padding-left: 10px;"><input class=formtext type=checkbox name=txtCreative value="Whoopee: 30 seconds" onClick="BoxClicked(); GetGroup();">
30 seconds</td>
</tr>
<tr>
<td valign=top class=formtext width="150" align="right" style="padding-top: 3px;"><b>Titanic:</b></td>
<td class=formtext style="padding-left: 10px;"><input class=formtext type=checkbox name=txtCreative value="Titanic: 30 seconds" onClick="BoxClicked(); GetGroup();">
30 seconds</td>
<td class=formtext style="padding-left: 10px;"><input class=formtext type=checkbox name=txtCreative value="Titanic 25/05" onClick="BoxClicked(); GetGroup();">
:25/:05</td>
</tr>
<tr>
<td valign=top class=formtext width="150" align="right" style="padding-top: 3px;"><b>Water Cooler:</b></td>
<td class=formtext style="padding-left: 10px;"><input class=formtext type=checkbox name=txtCreative value="Water Cooler: 30 seconds" onClick="BoxClicked(); GetGroup();">
30 seconds</td>
<td class=formtext style="padding-left: 10px;"><input class=formtext type=checkbox name=txtCreative value="Water Cooler: 25/05" onClick="BoxClicked(); GetGroup();">
:25/:05</td>
</tr>
</table>
<script language="javascript">
<!--
function BoxClicked(event) {
var objForm=document.forms["frm"];
var arrCheckBoxes=GetGroup(objForm, "txtCreative");
//count how many are checked
var checkedCount=0;
for (var i=0; i<arrCheckBoxes.length; i++) {
checkedCount += (arrCheckBoxes[i].checked)?1:0;
}
if (checkedCount >= 2) {
for (var i=0; i<arrCheckBoxes.length; i++) {
if (arrCheckBoxes[i].checked == false) {
arrCheckBoxes[i].disabled = "disabled";
}
}
}
}
function GetGroup(objForm, strName) {
//returns array with all elements having the name given in strName
var result=new Array();
for (var i=0; i<objForm.elements.length; i++) {
var element=objForm.elements[i];
if (element.name == strName) {
result[result.length] = element;
}
}
return result;
}
//-->
</script>
Jeg vil gerne have at man maks kan vælge 2 checkboxe - dvs når man har valgt 2 så bliver resten disabled
men jeg får denne fejl
objForm has no properties
er der nogen der kan se hvad der går galt - skal virke både i FF og IE