John Davidson

php - I want the first checkbox to be autochecked when any of the other checkox are checked

0 comments
Message:


<div class="form-group row">
<div class="col-xs-10">
<h5 style="margin-bottom: 12px;">@lang('admin.roles.pages')</h5>
</div>
<div class="col-xs-12">
<div class="col-xs-2">
<?php
$page_view = check_permission('pagelist', $id);
?>
<input <?php if ($page_view == 1) {
echo 'checked=checked';
} ?> style="float: left;" type="checkbox" value="admin.List-Page" name="roles[pagelist]" id="pageview">
<label style="float: left; margin-left: 5px; margin-top: 6px;" for="pageview">View</label>
</div>

<div class="col-xs-2">
<?php
$page_create = check_permission('pagecreate', $id);
?>
<input <?php if ($page_create == 1) {
echo 'checked=checked';
} ?> style="float: left;" type="checkbox" value="admin.Create-Page" name="roles[pagecreate]" id="pagecreate">
<label style="float: left; margin-left: 5px; margin-top: 6px;" for="pagecreate">Create</label>
</div>

<div class="col-xs-2">
<?php
$page_edit = check_permission('pageedit', $id);
?>
<input <?php if ($page_edit == 1) {
echo 'checked=checked';
} ?> style="float: left;" type="checkbox" value="admin.Edit-Page" name="roles[pageedit]" id="pageedit">
<label style="float: left; margin-left: 5px; margin-top: 6px;" for="pageedit">Edit</label>
</div>

<div class="col-xs-2">
<?php
$page_delete = check_permission('pagedelete', $id);
?>
<input <?php if ($page_delete == 1) {
echo 'checked=checked';
} ?> style="float: left;" type="checkbox" value="admin.Delete-Page" name="roles[pagedelete]" id="pagedelete">
<label style="float: left; margin-left: 5px; margin-top: 6px;" for="pagedelete">Delete</label>
</div>

Here I want checkbox view to be autoselected when checkbox create or delete or update are checked.
that is keeping the view checkbox selected automatically while selecting any of the other



My Answer:
You can achieve this using jQuery. Add the following script to your HTML file:

html




This script listens for changes on the checkboxes with ids `pagecreate`, `pageedit`, and `pagedelete`. When any of these checkboxes are checked, it will automatically check the checkbox with id `pageview`.

Rate this post

3 of 5 based on 7478 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us