Support the ongoing development of Laravel.io →
posted 10 years ago
Input Forms
Last updated 2 years ago.
0

Hi,

you can do this with javascript.

Try to see this: http://stackoverflow.com/questions/8206565/check-uncheck-checkbox-with-javascript

Last updated 2 years ago.
0

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');
Last updated 2 years ago.
0

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;
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

shiva shiva Joined 24 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.