0
我有我的代碼HTML 4個單選按鈕:我怎麼知道哪個單選按鈕是在文件選擇HTML,嫩枝
<input id="spa-price" name="price" class="w3-radio" value="Spare {{ price.getSparePrice }}" type="radio">
<input id="spa-price" name="price" class="w3-radio" value="Repair {{ price.getRepairPrice }}" type="radio">
<input id="spa-price" name="price" class="w3-radio" value="Test {{ price.getTestPrice }}" type="radio">
<input id="spa-price" name="price" class="w3-radio" value="Std-Exchange {{ price.getExchangePrice }}" type="radio">
在後,我要輸出的隱藏字段與選定的值單選按鈕,如:
<input type="hidden" name="lt" value="{{ price.getLt }}">
我目前的代碼:
{% if $_POST['price'] == 'Spare' %}
<input type="hidden" name="lt" value="{{ price.getLt }}">
{% elseif $_POST['price'] == 'Repair' %}
<input type="hidden" name="lt" value="{{ 10 }}">
{% elseif $_POST['price'] == 'Test' %}
<input type="hidden" name="lt" value="{{ 10 }}">
{% else $_POST['price'] == 'Exchange' %}
<input type="hidden" name="lt" value="{{ price.getLt }}">
目前,這是行不通的。
我的錯誤是什麼?謝謝。
恐怕你的問題是有點不清楚我。主要是錯誤的一部分。你拿到了嗎?如果是的話,請顯示它。或者你想知道如何檢索這個錯誤? – KevinTheGreat
對不起,我的問題是如何在文件html.twig中對這些無線電對象進行測試。 – sirine
我改變了它,但它沒有工作:{%if price.Spare == 1%} > {%elseif price.Test == 1%} {%elseif price.Repair == 1%} {%else%} {%endif% } – sirine