Thanks,
Am at home now, but I'll give it a try tomorrow.
larry
On 7/21/05, Marlon Moyer <[EMAIL PROTECTED]> wrote:
> function checkForNoSelections(){
>
> var chkd = 0;
> var e = document.viewItems;
>
> if(e.atccNum.length) {
> for(var i = 0; i < e.atccNum.length; i++){
> if(e.atccNum[i].checked == true){
> chkd = ++chkd;
> }
> }
> }
> else {
> if (e.atccNum.checked) chkd++;
> }
> if(chkd > 0){
> alert(chkd);
> return false;
> }
> else{
> alert("You must select an item to display.");
> return false;
> }
> }
>
> </script>
>
>
> On 7/21/05, Marlon Moyer <[EMAIL PROTECTED]> wrote:
> > Aha! I see what you mean.
> >
> > From the JS reference:
> >
> > name .
> >
> > A string specifying the checkbox's name.
> > Security JavaScript 1.1. This property is tainted by default. For
> > information on data
> > tainting, see the Client-Side JavaScript Guide.
> >
> > Description
> >
> > If multiple objects on the same form have the same NAME attribute, an array
> > of
> > the given name is created automatically. Each element in the array
> > represents
> > an individual Form object. Elements are indexed in source order starting at
> > 0.
> > For example, if two Text elements and a Button element on the same form
> > have their NAME attribute set to "myField", an array with the elements
> > myField[0], myField[1], and myField[2] is created. You need to be aware
> > of this situation in your code and know whether myField refers to a single
> > element or to an array of elements.
> >
> >
> > On 7/21/05, Larry C. Lyons <[EMAIL PROTECTED]> wrote:
> > > 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"> 1<br />
> > > > > <input type="button" value="View Selections"
> > > > > onClick="checkForNoSelections()"><br />
> > > > > <input type="Reset" value="Clear Selections"><br />
> > > > > </form>
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:5:165858
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