Overclockers Australia Forums
OCAU News - Wiki - QuickLinks - Pix - Sponsors  

Go Back   Overclockers Australia Forums > Software Topics > Programming & Software Development

Notices


Sign up for a free OCAU account and this ad will go away!
Search our forums with Google:
Reply
 
Thread Tools
Old 16th September 2002, 10:37 PM   #1
Tanus Thread Starter
Member
 
Tanus's Avatar
 
Join Date: Jun 2001
Location: Melbourne
Posts: 924
Default Checkbox arrays and Javascript

I'm trying to perform the following (see here for an example, it shows it better ), with these extras...

When I click one of the parent nodes (one of those checkbox things) I want to fill each of the child nodes as checked. There's two easy ways to do this; by making them checked to begin with when they're hidden (but I'd prefer not to as then those checkboxes will still be sent with the form), or using a name without [] brackets in it, which will suck a bit because it's a lot easier processing all these checkboxes as an array on the other side of the server.

I've found the following bit of code about checkboxes, but I tried it a way I thought it might work and nothing happened, can anyone shed any more light on it?

http://www.faqts.com/knowledge_base/.../10757/fid/310

The actual code for the checkboxes looks as follows (and works fine when using the form data in the action script)

PHP Code:

<form name="advancedsearch" method="GET" action="search.php">

        <!-- 
THE STALIN'S VISITOR'S BRANCH -->
        <
div class="trigger" onClick="
        showBranch('stv_branch',document.advancedsearch.stv);
        changeCheckbox(document.advancedsearch.stva[0], true);
        "
>
        <
input type="checkbox" name="stv" value="stalin_visit">
        
Stalins Visitors<br>
        </
div>
        <
span class="branch" id="stv_branch">
        <
input type="checkbox" name="stva[]" value="person.name" checked>
        
Name<br>
        <
input type="checkbox" name="stva[]" value="stv.date" checked>
        
Date<br>
        <
input type="checkbox" name="stva[]" value="stv.start" checked>
        
Start<br>
        <
input type="checkbox" name="stva[]" value="stv.end" checked>
        
End<br>
        <
input type="checkbox" name="stva[]" value="stv.notes" checked>
        
Notes<br>
        </
span
The changecheckbox function merely toggles the paramater from true to false, but I don't know how to pass a checkbox that is part of an array... any pointers?

Last edited by Tanus; 16th September 2002 at 10:40 PM.
Tanus is offline   Reply With Quote

Join OCAU to remove this ad!
Old 17th September 2002, 2:32 AM   #2
GooSE
Member
 
GooSE's Avatar
 
Join Date: Jun 2001
Location: Sydney
Posts: 6,427
Default

AFAIK the code you have should be work. That's quite strange that it doesn't. I had a quick look through 2 Java books to try and find anything to suggest otherwise, but I didn't find anything.

GooSE is offline   Reply With Quote
Old 17th September 2002, 3:23 AM   #3
Geo
Member
 
Join Date: Jun 2001
Location: Adelaide
Posts: 2,377
Default

Quote:
Originally posted by GooSE

I had a quick look through 2 Java books to try and find anything to suggest otherwise, but I didn't find anything.
Im not surprised. Try a Javascript book.
__________________
"That's the way good software gets designed. So if you pull out a piece it won't run" - Steve Ballmer
Geo is offline   Reply With Quote
Old 17th September 2002, 4:16 AM   #4
DigitalMonk
Member
 
DigitalMonk's Avatar
 
Join Date: Jun 2001
Location: St. Albert, Alberta, CANA
Posts: 1,130
Default

I'm not sure that I completely understand your problem. But I think that it is with the HTML rather than the JS. Try checked=true. Might fix your problem. I had a lot of probelms with checkboxes a few months ago, can't remeber all the things I did to fix 'em.
__________________
22" ViewSonic P225f, Lian-Li PC68, Enermax 465, Tyan Tiger MPX, Dual XP2400, 512MB REG ECCDDRSDRAM, Asus 9280 TD Geforce ti4200, 4x60GB, 160GB, 250GB
Folding@Home V3 1000 Club Member
Folding@Home 12500 Points Milestone
est. July 2001
DigitalMonk is offline   Reply With Quote
Old 17th September 2002, 1:36 PM   #5
GooSE
Member
 
GooSE's Avatar
 
Join Date: Jun 2001
Location: Sydney
Posts: 6,427
Default

Quote:
Originally posted by Geo
Im not surprised. Try a Javascript book.
Yes thats right, I'm a complete tool. But have a look at the time I posted that.

Yeah... That's a good excuse.
GooSE is offline   Reply With Quote
Old 17th September 2002, 2:15 PM   #6
Tanus Thread Starter
Member
 
Tanus's Avatar
 
Join Date: Jun 2001
Location: Melbourne
Posts: 924
Default

I found out the problem. Mozilla based browsers have changed the way form elements can be accessed to be more standards compliant. Microsoft doesn't of course. So I've had to change the way the bracket named elements are accessed.
Tanus is offline   Reply With Quote
Reply

Bookmarks

Sign up for a free OCAU account and this ad will go away!

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +10. The time now is 8:28 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. -
OCAU is not responsible for the content of individual messages posted by others.
Other content copyright Overclockers Australia.
OCAU is hosted by Internode!