/    Sign up×
Community /Pin to ProfileBookmark

how to check a checkbox if the other checkboxes are selected

Hello

I Have a problem.
I’ve searched all the check and uncheck buttons made from javascript but I have a different situation:

Given:
a.) 1 header checkbox [name=”chk”] (the check and unchecked button) – (if this checkbox is checked, all the other 10 buttons will be selected)
b.) 10 checkboxes [name=”checked”] (once all of this checkboxes are selected, the checkbox (A) of the header must be automatically enabled)

I have the following script for checkALL function:

[code=php]function checkAll(theElement) {
var theForm = theElement.form, z = 0;
for(z=0; z<theForm.length;z++){

if(theForm[z].type == ‘checkbox’ && theForm[z].name != ‘checkall’){
theForm[z].checked = theElement.checked;
}
}
}

[/code]

Question:

How can I recycle this script so that if all of my 10 checkboxes are selected, the header checkbox will be enabled?

Hope someone can help me on this. thank you!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @otixz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...