Get checked radio button value dynamically in Laravel 8

2.7k Views Asked by At

Suppose I have two radio buttons related to product pricing. I want to show the product price according to the selection of radio button. As an example if you select regular price radio button, I want show you regular price of the product. And if you select extended price radio button, I wanna show you extended price of the product. How can I do this in Laravel 8? Here is the related code:

<h3>${{$item_price}}</h3> // this $item_price is depends on the radio button which customer select.

<div class="custom-radio">
  <input type="radio" id="opt1" class="item-price" value="100" name="item_price" checked>
  <label for="opt1" data-price="100">
    <span class="circle"></span> Regular Price
  </label>
</div>

<div class="custom-radio">
  <input type="radio" id="opt2" class="item-price" value="150" name="item_price" checked>
  <label for="opt1" data-price="150">
    <span class="circle"></span> Extended Price
  </label>
</div>

I'm new in laravel, I try with Form::radio("item_price", "value"), but it gives me the radio button(DOM Element) instead of the value!

Is there any easy way to get the selected/checked radio button value in laravel 8 or php 7 ?

1

There are 1 best solutions below

0
On
<input type="radio" value="1" name="gt" checked>
<label>Man</label>
<input type="radio" value="0" name="gt">
<label>Women</label>

controller:
$sex = $request->gt;
//$sex = 1 or 0