Thank you, Tim! That's it. I knew an array was only created when the name
was used more than once, but it just didn't sink in! Agh! Silly, me! Let me
try to sort through this with what you told me and if I get stuck again I'll
contact you offlist. -It may take me a few days to get back to it, I'm
writing up a Standards Document at the moment (yuck). 

Thanks so much.

-Cheryl


-----Original Message-----
From: Furry, Tim [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 8:41 AM
To: [EMAIL PROTECTED]
Subject: [wdvltalk] Dynamic Checkboxes and Javascript Validation in ASP


Cheryl wrote:
I am having a problem with dynamic checkboxes and validation on an edit
page (update page) and am hoping someone can help me out. The code gives
me the correct checkboxes. But the validation doesn't recognize
'submissions.chkManagement.0' if there is only one checkbox - more than
one checkbox and it works. Why isn't
document.submissions.chkManagement.0 an object? Error Message: When only
1 box is written, e.g. Managers or AsstManager, the validation checking
returns an alert box stating,

        "Please select the management levels that are allowed to see
this link." 
        Hit, "Ok". (The only option)
        And you get...

                'A runtime error has occurred.
                Do you wish to Debug?

                Line: 102
                Error: 'document.submissions.chkManagement.0' is null or
not an object'

Tim:
Cheryl, the problem is because you only have one checkbox on the page.
When you have more than one checkbox named the same name, they are set
up as an array of checkboxes, and there is a "zero" element checkbox;
hence 'submissions.chkManagement.0' works (although I usually use
something like 'submissions.chkManagement[0].checked').  When only one
checkbox is on the page, an array is *not* created, so there isn't a
"zero" element in the page, even though the element is there.  You must
refer to a single checkbox by it's name only, without an array index.

I've had this problem too; the only way I could figure out how to work
around it neatly and quickly was to set up a hidden field on the page
that indicated whether there was only one checkbox or more than one
checkbox present.  Then in the validation code (either client or server
side) I check the value of the hidden field and use code forks with
appropriate checkbox names to validate the value of the checkbox.  If
you need more info contact me offlist and I'll hunt up where I did it
and show you.  It's pretty easy.

Tim
___________________________ 
Tim Furry
Web Developer 
Foulston Siefkin LLP 




____ * The WDVL Discussion List from WDVL.COM * ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] 
       Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
    http://wdvl.internet.com/WDVL/Forum/#sub

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to %%email.unsub%%

____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] 
       Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
    http://wdvl.internet.com/WDVL/Forum/#sub

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to