Home » » Check uncheck all checkboxes javascript

Check uncheck all checkboxes javascript

Written By Unknown on Jumat, 29 April 2011 | 00.52

Hi friends. To check or uncheck form check boxes, use this javascript function.


The Html Form [ For static contents ]

 <script type="text/javascript">
function checkAll(formName, status){
for (i = 0; i < formName.length; i++)
formName[i].checked = status.checked? true:false
}
</script>

<form name ="checkForm">
<input type="checkbox" name="all"
onClick="checkAll(this.form,this)">Check/Uncheck All
<input type="checkbox" name="one" value ="one">One
<input type="checkbox" name="two" value ="two">Two
<input type="checkbox" name="three" value ="three">Three
<input type="checkbox" name="four" value ="four">Four
<input type="checkbox" name="five" value ="five">Five
</form>


The Php Form [ For Dynamic contents ]

 <script type="text/javascript">
function checkAll(formName, status){
for (i = 0; i < formName.length; i++)
formName[i].checked = status.checked? true:false
}
</script>

<form name ="checkForm">
<input type="checkbox" name="all"
onClick="checkAll(this.form,this)">Check/Uncheck All
<?php
mysql_connect('localhost','username','password');
mysql_select_db('databaseName');

$sql="select id,name from tableName";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res)){
echo '<input type="checkbox" name="chk[]"
value ='.$row["id"].'>'.$row["name"].'<br>';
}
?>
</form>


The Example


Check/Uncheck All
One
Two
Three
Four
Five
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger