假设我有两个与产品定价相关的单选按钮。我想根据单选按钮的选择显示产品价格。例如,如果您选择regular price
单选按钮,我想向您展示产品的常规价格。如果你选择extended price
单选按钮,我想向你展示产品的扩展价格。我如何在Laravel 8中做到这一点?这是相关代码:
<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>
我是laravel的新手,我尝试使用Form::radio("item_price", "value")
,但它给了我单选按钮(DOM元素(而不是值!
有没有什么简单的方法可以在laravel 8或php7中获得选中/检查的单选按钮值?
<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