Now take out the hidden form field and make sure there's only one
checkbox field. It works fine with multiple fields of the same name,
even if only one of them is a checkbox. But, if there is only one
field with that name the validation always resolves to false.

larry

On 7/21/05, Marlon Moyer <[EMAIL PROTECTED]> wrote:
> Larry, your script works fine for me.  I had to add some radio buttons
> to test it, but it works as it should.
> 
> 
> On 7/21/05, Larry C. Lyons <[EMAIL PROTECTED]> wrote:
> > 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">&nbsp;&nbsp;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:165831
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

Reply via email to