大家好,如何获取选定的单选按钮值。我想将所选单选按钮的值存储在我的表格中。
我的控制器代码传递给视图 $result
$result = DB::table('table')
->where('name', $name)
->where('code', $code)
->get();
return View::make('home.search_result')
->with('result', $result);
在我的代码中,我有一个单选按钮。
{{ Form::open(array('action' => 'BookingController@postValue', 'class'=>'well', 'method' => 'GET')) }}
<table id="search" class="table table-striped table-hover">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Code</th>
</tr>
</thead>
<tbody>
@foreach($result as $result)
<tr class="success">
<td>{{ Form::radio('result') }}
<td>{{ $result->name}}</td>
<td>{{ $result->code}}</td>
</tr>
@endforeach
</tfoot>
</table>
{{ Form::submit('Add', array('class' => 'btn btn-info')) }}
{{ Form::close() }}
当我点击“添加”按钮时,我尝试将选中的单选框的值传递给我的“postValue”函数。
result[]
。然后Input::get('result');
将包含一个值数组。 - Jason Lewis