Hi,
you can do this with javascript.
Try to see this: http://stackoverflow.com/questions/8206565/check-uncheck-checkbox-with-javascript
So far I've managed to get the checkbox to display the correct value in the value section. But I can't seem to do anything else.
My index page
<table>
{{ Form::open(array('action' => 'admin\MenuController@checkdelete')) }}
{{ Form::submit('Delete') }}
{{ Form::close() }}
@foreach($menu as $menu)
<tr>
<td>
{{ link_to_route('admin.menu.edit', $menu->title, array($menu->id)) }}
</td>
<td>
{{ Form::open(array('action' => 'admin\MenuController@checkdelete')) }}
{{ Form::checkbox('my_checkbox', $menu->id) }}
{{ Form::close() }}
</td>
<td>
{{ Form::open(array('method' => 'Delete', 'route' => array('admin.menu.destroy', $menu->id), 'class' => 'delete-form')) }}
{{ Form::submit('Delete', array('class' => 'btn btn-danger', 'role' => 'button')) }}
{{ Form::close() }}
</td>
</tr>
@endforeach
</table>
controller
public function checkdelete($id){
if (\Input::get('my_checkbox') == $id)
{
// Checkbox is checked
echo 'yes';
}
else
{
// Checkbox is not checked
echo 'no';
}
}
route
Route::get('admin/menu/checkdelete', 'admin\MenuController@checkdelete');
When I put the
//Check if checbox is checked
document.getElementById("my_checkbox").checked = true;
//check if checkbox is unchecked
document.getElementById("my_checkbox").checked = false;
I get this error
TypeError: document.getElementById(...) is null
document.getElementById("my_checkbox").checked = true;
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community