Search code examples
laravel-5radio-buttonlaravel-blade

How to get 2 value from 1 radio button on laravel?


I am stuck on this problem, I just want to get 2 value from one radio button, for example :

{{ Form::radio('jenjang','D1|6',true,['class' => 'with-gap']) }}

When I checked that radio button, I want to get "D1" and "6" without Java script, is it possible? How to do that in Laravel 5.5? Thanks in advance, I hope someone can help me.


Solution

  • You don't really need to get both values from the checkbox.

    The 'jenjang' radio button can have the value 'D1'.

    {{ Form::radio('jenjang','D1',true,['class' => 'with-gap']) }}
    

    In your controller, get the value of the radio button and then also set the second value based on that:

    $value1 = $request->input('jenjang');
    if ($value1 == 'D1') {
        $value2 = 6;
    }