我有一个表单,我可以编辑内容,此时我正在回复输入字段中复选框的值,但我宁愿保留原始复选框并显示哪个已被选中。
<div class="col-sm-9">
<label class="checkbox-inline">
<input type="radio" class="px" name="radiochoice" id="radio11" class="radio" value="No Charge" />
<span class="lbl">No Charge</span>
</label>
<br>
</div>
<div class="col-sm-9">
<label class="checkbox-inline">
<input type="radio" class="px" name="radiochoice" id="radio7" class="radio" value="185.00" />
<span class="lbl">Networking: $185.00</span>
</label>
<br>
</div>
<div class="col-sm-9">
<label class="checkbox-inline">
<input type="radio" class="px" name="radiochoice" id="radio8" class="radio" value="125.00"/>
<span class="lbl">Mechanical: $125.00</span>
</label>
<br>
</div>
如果我回显它只显示值的值,我该如何显示选中了哪个复选框?
value=<?php echo $radiochoice;?>>
目标:
if ($radiochoice == "No Charge") {
echo '<div class="col-sm-9">';
echo '<label class="checkbox-inline">';
echo '<input type="radio" class="px" name="radiochoice" id="radio11" class="radio" value="No Charge" checked/>';
echo '<span class="lbl">No Charge</span>';
echo '</label>';
echo '<br>';
echo '</div>';
echo '<div class="col-sm-9">';
echo '<label class="checkbox-inline">';
echo '<input type="radio" class="px" name="radiochoice" id="radio7" class="radio" value="185.00" />';
echo '<span class="lbl">Networking: $185.00</span>';
echo '</label>';
echo '<br>';
echo '</div>';
echo '<div class="col-sm-9">';
echo '<label class="checkbox-inline">';
echo '<input type="radio" class="px" name="radiochoice" id="radio8" class="radio" value="125.00" />';
echo '<span class="lbl">Mechanical: $125.00</span>';
echo '</label>';
echo '<br>';
echo '</div>';
echo '<div class="col-sm-9">';
echo '<label class="checkbox-inline">';
echo '<input type="radio" class="px" name="radiochoice" id="radio9" class="radio" value="59.00" />';
echo '<span class="lbl">Remote half: $59.00</span>';
echo '</label>';
echo '<br>';
echo '</div>';
echo '<div class="col-sm-9">';
echo '<label class="checkbox-inline">';
echo '<input type="radio" class="px" name="radiochoice" id="radio10" class="radio" value="89.00" />';
echo '<span class="lbl">Remote 1 HR: $89.00</span>';
echo '</label>';
echo '<br>';
echo '</div>';
} elseif ($answer == 185.00) {
答案 0 :(得分:1)
虽然你可以添加的每个输入都不优雅
defer
相应地更改值,它可能是$ _GET,具体取决于表单操作