I'm having a problem with a javascript validation for a form with
multiple checkboxes named the same. It works just fine when there is
more than one checkbox, but, if there is only one it always validates
to false and craps out. Any suggestions would be most appreciated.
thx,
larry
Here's the javascript:
<script language="javascript" type="text/javascript">
function checkForNoSelections(){
var chkd = 0;
var e = document.viewItems;
for(var i = 0; i < e.atccNum.length; i++){
if(e.atccNum[i].checked == true){
chkd = ++chkd;
}
}
if(chkd > 0){
e.submit();
return true;
}
else{
alert("You must select an item to display.");
return false;
}
}
</script>
Here's the form:
<form action="multiSelectTest.htm" enctype="multipart/form-data"
method="post" name="viewItems">
<input type="hidden" name="hiddenField" value="" />
<input type="Checkbox" name="atccNum" value="1"> 1<br />
<input type="button" value="View Selections"
onClick="checkForNoSelections()"><br />
<input type="Reset" value="Clear Selections"><br />
</form>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:5:165812
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54