JS help - checkboxes

2004-04-09 Thread Tim Laureska
I have a little script that throws up an alert when more than 1 checkbox
is selected.However, is there some code I can put in this script that
will also prevent anything else in the cold fusion page from processing
until the more than one checkbox problem is corrected?Here's the
script:

SCRIPT LANGUAGE=_javascript_
!-- Begin
function anyCheck(form) {
var total = 0;
var max = form.type_no.length;
for (var idx = 0; idx  max; idx++) {
if (eval(document.registration.type_no[ + idx + ].checked) == true)
{
 total += 1;
if (total 1) alert(You cannot select more than 1 registration type);
}
}

}
//End --
/script

TIA
Tim
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JS help - checkboxes

2004-04-09 Thread Adkins, Randy
If your calling that script from the OnSubmit function of your form tag,
simply return FALSE to the call:

 
FORM ACTION="" ACTION PAGE NAME=myFORM >
anyCheck('myForm')

Then in the script:
if (eval(document.registration.type_no[ + idx + ].checked) == true)
{
 total += 1;
if (total 1) alert(You cannot select more than 1 registration type);
return false
}
}
return true

This is of course you need no other validation

-Original Message-
From: Tim Laureska [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 09, 2004 8:52 AM
To: CF-Talk
Subject: JS help - checkboxes

I have a little script that throws up an alert when more than 1 checkbox
is selected.However, is there some code I can put in this script that
will also prevent anything else in the cold fusion page from processing
until the more than one checkbox problem is corrected?Here's the
script:

SCRIPT LANGUAGE=_javascript_
!-- Begin
function anyCheck(form) {
var total = 0;
var max = form.type_no.length;
for (var idx = 0; idx  max; idx++) {
if (eval(document.registration.type_no[ + idx + ].checked) == true)
{
 total += 1;
if (total 1) alert(You cannot select more than 1 registration type);
}
}

}
//End --
/script

TIA
Tim 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JS help - checkboxes

2004-04-09 Thread Lofback, Chris
Would it make more sense to use radio buttons, which only allow one selection?

 
Chris 

-Original Message-
From: Tim Laureska [mailto:[EMAIL PROTECTED]
Sent: Friday, April 09, 2004 8:52 AM
To: CF-Talk
Subject: JS help - checkboxes

I have a little script that throws up an alert when more than 1 checkbox
is selected.However, is there some code I can put in this script that
will also prevent anything else in the cold fusion page from processing
until the more than one checkbox problem is corrected?Here's the
script:

SCRIPT LANGUAGE=_javascript_
!-- Begin
function anyCheck(form) {
var total = 0;
var max = form.type_no.length;
for (var idx = 0; idx  max; idx++) {
if (eval(document.registration.type_no[ + idx + ].checked) == true)
{
 total += 1;
if (total 1) alert(You cannot select more than 1 registration type);
}
}

}
//End --
/script

TIA
Tim 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JS help - checkboxes

2004-04-09 Thread Tim Laureska
Ahh... I didn't know that... never used radio buttons before ... I'll
check out that possibility

-Original Message-
From: Lofback, Chris [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 09, 2004 9:10 AM
To: CF-Talk
Subject: RE: JS help - checkboxes

Would it make more sense to use radio buttons, which only allow one
selection?

 
Chris 

-Original Message-
From: Tim Laureska [mailto:[EMAIL PROTECTED]
Sent: Friday, April 09, 2004 8:52 AM
To: CF-Talk
Subject: JS help - checkboxes

I have a little script that throws up an alert when more than 1 checkbox
is selected.However, is there some code I can put in this script that
will also prevent anything else in the cold fusion page from processing
until the more than one checkbox problem is corrected?Here's the
script:

SCRIPT LANGUAGE=_javascript_
!-- Begin
function anyCheck(form) {
var total = 0;
var max = form.type_no.length;
for (var idx = 0; idx  max; idx++) {
if (eval(document.registration.type_no[ + idx + ].checked) == true)
{
 total += 1;
if (total 1) alert(You cannot select more than 1 registration type);
}
}

}
//End --
/script

TIA
Tim 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JS help - checkboxes

2004-04-09 Thread Tim Laureska
Thanks Chris... was easy and works great

Randy... thanks also for your suggestion on the checkbox approach

-Original Message-
From: Lofback, Chris [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 09, 2004 9:10 AM
To: CF-Talk
Subject: RE: JS help - checkboxes

Would it make more sense to use radio buttons, which only allow one
selection?

 
Chris 

-Original Message-
From: Tim Laureska [mailto:[EMAIL PROTECTED]
Sent: Friday, April 09, 2004 8:52 AM
To: CF-Talk
Subject: JS help - checkboxes

I have a little script that throws up an alert when more than 1 checkbox
is selected.However, is there some code I can put in this script that
will also prevent anything else in the cold fusion page from processing
until the more than one checkbox problem is corrected?Here's the
script:

SCRIPT LANGUAGE=_javascript_
!-- Begin
function anyCheck(form) {
var total = 0;
var max = form.type_no.length;
for (var idx = 0; idx  max; idx++) {
if (eval(document.registration.type_no[ + idx + ].checked) == true)
{
 total += 1;
if (total 1) alert(You cannot select more than 1 registration type);
}
}

}
//End --
/script

TIA
Tim 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JS help - checkboxes

2004-04-09 Thread Lofback, Chris
Glad to help.Here's one more tip.If you want HTML checkboxes and radio buttons to activate by clicking on the label (like other form-based apps), try this snippet of code:

 
LABEL FOR="" TYPE=radio ID=RB1 NAME=Foo VALUE=1Option 1/LABEL

 
I don't think it works on every browser, but it works on most modern ones and the others just ignore the LABEL tags.Note that the FOR parameter of the LABEL tag must match the ID parameter of the radio button or checkbox.

 
Chris

-Original Message-
From: Tim Laureska [mailto:[EMAIL PROTECTED]
Sent: Friday, April 09, 2004 9:46 AM
To: CF-Talk
Subject: RE: JS help - checkboxes

Thanks Chris... was easy and works great

Randy... thanks also for your suggestion on the checkbox approach

-Original Message-
From: Lofback, Chris [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 09, 2004 9:10 AM
To: CF-Talk
Subject: RE: JS help - checkboxes

Would it make more sense to use radio buttons, which only allow one
selection?

Chris 

-Original Message-
From: Tim Laureska [mailto:[EMAIL PROTECTED]
Sent: Friday, April 09, 2004 8:52 AM
To: CF-Talk
Subject: JS help - checkboxes

I have a little script that throws up an alert when more than 1 checkbox
is selected.However, is there some code I can put in this script that
will also prevent anything else in the cold fusion page from processing
until the more than one checkbox problem is corrected?Here's the
script:

SCRIPT LANGUAGE=_javascript_
!-- Begin
function anyCheck(form) {
var total = 0;
var max = form.type_no.length;
for (var idx = 0; idx  max; idx++) {
if (eval(document.registration.type_no[ + idx + ].checked) == true)
{
 total += 1;
if (total 1) alert(You cannot select more than 1 registration type);
}
}

}
//End --
/script

TIA
Tim 
_ 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]