JAVA SCRIPT

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
jackass007
Posts: 18
Joined: Tue Mar 16, 2010 5:38 pm UTC

JAVA SCRIPT

Postby jackass007 » Fri Mar 18, 2011 8:45 am UTC

is somebody can gv me some information on how to do when the parent checkbox is checked all the child checkboxes will be checked by using java script.
On the contrary, while i uncheck parent checkbox, it will automatically uncheck all the child checkboxes. thx .^^

Hope to hear good news from U ^^

User avatar
Emu*
Posts: 689
Joined: Mon Apr 28, 2008 9:47 am UTC
Location: Cardiff, UK
Contact:

Re: JAVA SCRIPT

Postby Emu* » Fri Mar 18, 2011 10:53 am UTC

include jQuery (see docs.jquery.com), then in the onclick of your "parent checkbox" you can select each of your child ones and select or unselect.

Code: Select all

<label for="parent">This is the parent</label>
<input type="checkbox" id="parent" name="parent" onclick="$('#others input').attr('checked',this.checked);" />
<fieldset id="others"><legend>These checkboxes are children</legend>
    <label for="child1">This is the 1st child</label><input type="checkbox" id="child1" name="child1"/>
    <label for="child2">This is the 2nd child</label><input type="checkbox" id="child2" name="child2"/>
    <label for="child3">This is the 3rd child</label><input type="checkbox" id="child3" name="child3"/>
</fieldset>
Cosmologicon wrote:Emu* implemented a naive east-first strategy and ran it for an hour, producing results that rivaled many sophisticated strategies, visiting 614 cells. For this, Emu* is awarded Best Deterministic Algorithm!

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Javascript

Postby sourmìlk » Fri Mar 18, 2011 11:20 pm UTC

jackass007 wrote:Can somebody please give me some information on how to make it so that the "checked" state of a parent checkbox determines the checked state of its children checkboxes?

I hope to hear good news from you.


I don't know if you were intentionally obfuscating your speech, but god damn it bugged me. FTFY
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

User avatar
Dason
Posts: 1311
Joined: Wed Dec 02, 2009 7:06 am UTC
Location: ~/

Re: Javascript

Postby Dason » Sat Mar 19, 2011 1:02 am UTC

sourmìlk wrote:I don't know if you were intentionally obfuscating your speech, but god damn it bugged me. FTFY

It bugged me too. A LOT.
double epsilon = -.0000001;


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 10 guests