/    Sign up×
Community /Pin to ProfileBookmark

chech & un-check all

Hi,
I have this js code works perfectly in checking and un-checking the checkboxes.

[code=html]<html>
<HEAD>
<script type=”text/javascript”>
<!–
function checkAll(checkname, exby) {
for (i = 0; i < checkname.length; i++)
checkname[i].checked = exby.checked? true:false
}
// –>
</script>
</HEAD>
<BODY>

<form name =”mylist”>
<input type=”checkbox” name=”checkGroup” value =”first”>First<br>
<input type=”checkbox” name=”checkGroup” value =”second”>Second<br>
<input type=”checkbox” name=”checkGroup” value =”third”>Third<br>
<input type=”checkbox” name=”checkGroup” value =”fourth”>Fourth<br>
<input type=”checkbox” name=”all” onClick=”checkAll(document.mylist.checkGroup,this)”>Check/Uncheck All<br>
</form>
</body>
</html>
[/code]

But i’m having problem in implementing it in my php code.
Because in my php i have my checkbox form variable is in array form
like this: multi_delete[]
so, how can make this script work ?
this is the php code

[code=php]
<form name =”mylist”>
<?php
//query here
while ($row = mysql_fetch_array($query)) {
$id = $row[‘id’];
echo “<input type=checkbox class=inputbordr name=’multi_delete[]’ value=’$id’><br>”;
}
echo “<input type=”checkbox” name=”all” onClick=”checkAll(document.mylist.multi_delete,this)”>Check/Uncheck All<br> “;
?>
</form>
[/code]

Thanks in advance

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @themoon 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...