[英]Laravel\Blade - get value of selected radio button dynamically added
[英]Get checked radio button value dynamically in Laravel 8
假設我有兩個與產品定價相關的單選按鈕。 我想根據單選按鈕的選擇顯示產品價格。 例如,如果您使用 select regular price
單選按鈕,我想向您顯示產品的正常價格。 如果您輸入 select 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 或 php 7 中獲取選中/選中的單選按鈕值?
<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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.