Checking that at least one check box is checked

Checking that at least one check box is checked

Post by Russel » Fri, 18 Nov 2005 10:13:08


Hello ,

I have a page that has multiple check boxes. I would like to make sure
that at least one check box is checked before the submit button sends the
form off to a shopping cart. Any help is appreciated.

Thanks,

Russell

http://www.yqcomputer.com/
 
 
 

Checking that at least one check box is checked

Post by Kathleen A » Fri, 18 Nov 2005 10:46:55

With JavaScript: http://www.yqcomputer.com/

--
~ Kathleen Anderson
Microsoft MVP - FrontPage
Spider Web Woman Designs
web: http://www.yqcomputer.com/

 
 
 

Checking that at least one check box is checked

Post by Russel » Fri, 18 Nov 2005 14:18:49

TY Kathleen

But that script proved too complicated for me. I was able to get it to do
what I wanted in its "own" page but upon pasting into my page it did not
work .

I pasted this:

<script Language="JavaScript">
<!--
function checkbox_checker()
{

// set var checkbox_choices to zero

var checkbox_choices = 0;

// Loop from zero to the one minus the number of checkbox button selections
for (counter = 0; counter < checkbox_form.checkbox.length; counter++)
{

// If a checkbox has been selected it will return true
// (If not it will return false)
if (checkbox_form.checkbox[counter].checked)
{ checkbox_choices = checkbox_choices + 1; }

}
if (checkbox_choices < 1 )
{
// If there were less then selections made display an alert box
alert("Please make a selection.")
return (false);
}
}

-->
</script>

And this :

<FORM METHOD=POST ACTION=" http://www.yqcomputer.com/ " onsubmit="return
checkbox_checker()" name="checkbox_form">


And get the results : checkbox_form.checkbox.length is null or not
an object.

Any other hints for me?

Thanks

Russell



"Kathleen Anderson [MVP - FrontPage]" < XXXX@XXXXX.COM > wrote in



the
 
 
 

Checking that at least one check box is checked

Post by Stefan B R » Fri, 18 Nov 2005 19:31:58

Are all your check boxes in your form named checkbox per the sample code
<input type="checkbox" value="Hank Aaron" name="checkbox">Hank Aaron<br>
That's what checkbox_form.checkbox.length is looking for
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.yqcomputer.com/
_____________________________________________



| TY Kathleen
|
| But that script proved too complicated for me. I was able to get it to do
| what I wanted in its "own" page but upon pasting into my page it did not
| work .
|
| I pasted this:
|
| <script Language="JavaScript">
| <!--
| function checkbox_checker()
| {
|
| // set var checkbox_choices to zero
|
| var checkbox_choices = 0;
|
| // Loop from zero to the one minus the number of checkbox button selections
| for (counter = 0; counter < checkbox_form.checkbox.length; counter++)
| {
|
| // If a checkbox has been selected it will return true
| // (If not it will return false)
| if (checkbox_form.checkbox[counter].checked)
| { checkbox_choices = checkbox_choices + 1; }
|
| }
| if (checkbox_choices < 1 )
| {
| // If there were less then selections made display an alert box
| alert("Please make a selection.")
| return (false);
| }
| }
|
| -->
| </script>
|
| And this :
|
| <FORM METHOD=POST ACTION=" http://www.yqcomputer.com/ " onsubmit="return
| checkbox_checker()" name="checkbox_form">
|
|
| And get the results : checkbox_form.checkbox.length is null or not
| an object.
|
| Any other hints for me?
|
| Thanks
|
| Russell
|
|
|
| "Kathleen Anderson [MVP - FrontPage]" < XXXX@XXXXX.COM > wrote in

| > With JavaScript: http://www.yqcomputer.com/
| >
| > --
| > ~ Kathleen Anderson
| > Microsoft MVP - FrontPage
| > Spider Web Woman Designs
| > web: http://www.yqcomputer.com/
| >
| >


| > > Hello ,
| > >
| > > I have a page that has multiple check boxes. I would like to make sure
| > > that at least one check box is checked before the submit button sends
| the
| > > form off to a shopping cart. Any help is appreciated.
| > >
| > > Thanks,
| > >
| > > Russell
| > >
| > > http://www.yqcomputer.com/
| > >
| > >
| >
| >
|
|
 
 
 

Checking that at least one check box is checked

Post by Russel » Fri, 18 Nov 2005 22:35:44

hanks Stefan.

I changed the names of the checkboxes and that script works fine. Problem is
my shopping cart expects the checkbox names to be multi-item1, multi-item2,
etc. I can't change those names and still have the shopping cart place a
checked item in the cart. Any suggestions?

Thanks

Russell

"Stefan B Rusynko" < XXXX@XXXXX.COM > wrote in message
news:ud$ XXXX@XXXXX.COM ...
news: XXXX@XXXXX.COM ...
do
selections
onsubmit="return
not
sure
sends


 
 
 

Checking that at least one check box is checked

Post by Thomas A. » Fri, 18 Nov 2005 22:59:32

ave you contact your shopping cart vendor for help with this issue?

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

"Russell" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ...


 
 
 

Checking that at least one check box is checked

Post by Russel » Fri, 18 Nov 2005 23:21:03

o I haven' to. I don't see it as a cart issue. The cart works fine. I
would just like to prevent submission to the cart with empty check boxes.
Its not a big deal, but to some, I suspect it might be annoying.
Not really knowing JavaScript, but having seen what can be done, I didn't
think it would be too difficult to check for input before submitting the
forms.

Any other suggestions how to do this?

Thank You.

Russell


"Thomas A. Rowe" < XXXX@XXXXX.COM > wrote in message
news:% XXXX@XXXXX.COM ...
news: XXXX@XXXXX.COM ...
Problem is
multi-item2,
code
Aaron<br>
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
to
not
or
in
http://www.codeave.com/javascript/code.asp?u_log=7062
make


 
 
 

Checking that at least one check box is checked

Post by Thomas A. » Fri, 18 Nov 2005 23:32:19

t is not a FP issue either, it is a cart issue, since you must name each checkbox uniquely, the
author may have a solution.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

"Russell" < XXXX@XXXXX.COM > wrote in message news:% XXXX@XXXXX.COM ...


 
 
 

Checking that at least one check box is checked

Post by Russel » Fri, 18 Nov 2005 23:44:44

hanks Thomas

"Thomas A. Rowe" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
checkbox uniquely, the
news:% XXXX@XXXXX.COM ...
boxes.
didn't
place a
it
did
counter++)
null
wrote
button


 
 
 

Checking that at least one check box is checked

Post by Russel » Sat, 19 Nov 2005 01:40:11

ell the author didn't have a solution... Anyone else? All I want to do is
make sure one of 2 or 3 checkboxes is checked off. All the checkboxes must
have unique names.

Much appreciated,

Russell

"Russell" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
each
I
the
sample
to


 
 
 

Checking that at least one check box is checked

Post by Thomas A. » Sat, 19 Nov 2005 02:12:51

f you want to use checkboxes and check client-side you are going to have to change / duplicate the
JavaScript code to check each checkbox so that the checking function has a corresponding name for
each check box you want to have checked.

Alternatively, can you use a drop down, where you can set it so that one item has to be selected?
--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

"Russell" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ...


 
 
 

Checking that at least one check box is checked

Post by Russel » Sat, 19 Nov 2005 02:35:03

homas,
I would rather not use drop down boxes. So the alternative you suggested is
ok by me. I will be using it in 50 - 60 pages that all have similar choices
(1-3 checkboxes) and all the check boxes will be similarly named.

Of course I do not know how to go about doing it, so your help is, as usual
greatly appreciated.

Thanks again,

Russell

"Thomas A. Rowe" < XXXX@XXXXX.COM > wrote in message
news:% XXXX@XXXXX.COM ...
to change / duplicate the
corresponding name for
item has to be selected?
news: XXXX@XXXXX.COM ...
is
must
fine.
submitting
issue?
fine.
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
get
it
button
box
is
< XXXX@XXXXX.COM >
like
http://www.kenortongallery.com/landscapes/americanlight.htm


 
 
 

Checking that at least one check box is checked

Post by Thomas A. » Sat, 19 Nov 2005 02:42:19

k, you will have to wait for someone that works with JavaScript more then I do to help you change
it to meet you needs.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

"Russell" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ...


 
 
 

Checking that at least one check box is checked

Post by Russel » Sat, 19 Nov 2005 03:13:31

do appreciate your efforts.

Thank you.


"Thomas A. Rowe" < XXXX@XXXXX.COM > wrote in message
news:% XXXX@XXXXX.COM ...
I do to help you change
news: XXXX@XXXXX.COM ...
is
choices
usual
have
has a
one
do
name
check
I
multi-item1,
cart
name="checkbox">Hank
to
page
alert
ACTION="http://www.myurl/cgi-bin/cart.pl"
checkbox_form.checkbox.length
submit


 
 
 

Checking that at least one check box is checked

Post by Russel » Sat, 19 Nov 2005 23:54:10

s this thread done ? Should I repost?

Russell

"Russell" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
then
suggested
to
checkboxes
works
annoying.
done,
call.
the
able
checkbox
checkbox_form.checkbox.length;
would
appreciated.