In programming we must design our site User-friendly.
So for that this thing is very useful
We can select multiple checkbox in a page with single click with the use of javascript
Here is the code for javascript
On which input you want to genrate this action just put the function on onclick event.
<inpt type="button" onclick="selectall()">
then genrate selectall function in javascript
<script type="text/javascript">
function selectall()
{
var chks = document.getElementsByName('del[]');
// here del[] is array name of your checkboxes
for(i=0;i<chks.length;i++)
{
chks[i].checked=true;
}
}
</script>
And one more thing when you assign name as an array to checkbox then put the unique value of that record as a value of checkbox.
Enjoy......
So for that this thing is very useful
We can select multiple checkbox in a page with single click with the use of javascript
Here is the code for javascript
On which input you want to genrate this action just put the function on onclick event.
<inpt type="button" onclick="selectall()">
then genrate selectall function in javascript
<script type="text/javascript">
function selectall()
{
var chks = document.getElementsByName('del[]');
// here del[] is array name of your checkboxes
for(i=0;i<chks.length;i++)
{
chks[i].checked=true;
}
}
</script>
And one more thing when you assign name as an array to checkbox then put the unique value of that record as a value of checkbox.
Enjoy......
Comments
Post a Comment