Hi friends. To check or uncheck form check boxes, use this javascript function.
The Html Form [ For static contents ]
The Php Form [ For Dynamic contents ]
The Example
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
Posting Komentar