如何在 Laravel 中获取选定的单选按钮值 [英] How to get selected radio button value in Laravel
本文介绍了如何在 Laravel 中获取选定的单选按钮值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,如何获取选定的单选按钮值.我想将值存储在选中单选按钮的表上.
Hi all how to get selected radio button value. I want to store values on my table where selected radio button.
我的控制器代码传递给 View $result
My Controller code passing to View $result
$result = DB::table('table')
->where('name', $name)
->where('code', $code)
->get();
return View::make('home.search_result')
->with('result', $result);
在我的视图代码中,我有单选按钮.
In my view code I had radio button.
{{ 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 函数.
So I try to pass chechked radio button value to my postValue function when I click Add button.
推荐答案
你需要给单选按钮一个值.你给它的只是一个名字.
You need to give the radio button a value. All you've given it is a name.
<td>{{ Form::radio('result', $result->code) }}
然后在处理表单的控制器中,您可以获取值.
Then in your controller that processes the form you can grab the value.
$result = Input::get('result');
这篇关于如何在 Laravel 中获取选定的单选按钮值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文