英文:
How can I convert the code in the following select tags into a radio button?
问题
可发货
建议
建议
上述代码中有两个选项,我想用单选按钮显示这两个选项,而不是使用下拉框。在我的实验中,我所做的更改总是重叠在一起,无法实现动态效果。谢谢你的帮助。
英文:
<div class="form-group m-form__group row col-12">
<label for="example-text-input" class="col-3 col-form-label">Approval Status</label>
<div class="col-9">
<select class="form-control m-input m-input--square" name="approvalstatus" required>
@if ((int)Model.PARAMETER.APPROVALSTATUS == 4)
{
<option selected value="4">Shipable</option>
}
else
{
<option value="4">Shipable</option>
}
@if ((int)Model.PARAMETER.APPROVALSTATUS == 1)
{
<option selected value="1">Suggestion</option>
}
else
{
<option value="1">Suggestion</option>
}
</select>
</div>
</div>
> There are two options in the above code, I want to show these two options with radio button, not with select. In my own experiments, the changes I made always overlapped and I could not make it dynamic. Thanks for your help.
答案1
得分: 2
我认为这是您期望的内容,
<div class="form-group m-form__group row col-12">
<label for="example-text-input" class="col-3 col-form-label">Approval Status</label>
<div class="col-9">
<label class="radio-inline">
<input type="radio" name="approvalstatus" value="4"
@if ((int)Model.PARAMETER.APPROVALSTATUS == 4)
{
checked
}
> Shipable
</label>
<label class="radio-inline">
<input type="radio" name="approvalstatus" value="1"
@if ((int)Model.PARAMETER.APPROVALSTATUS == 1)
{
checked
}
> Suggestion
</label>
</div>
</div>
更新:如Hans建议您这样做,
<input type="radio" name="approvalstatus" value="4" checked=@((int)Model.PARAMETER.APPROVALSTATUS == 4) required> Shipable
英文:
I think this is what you are expecting,
<div class="form-group m-form__group row col-12">
<label for="example-text-input" class="col-3 col-form-label">Approval Status</label>
<div class="col-9">
<label class="radio-inline">
<input type="radio" name="approvalstatus" value="4"
@if ((int)Model.PARAMETER.APPROVALSTATUS == 4)
{
checked
}
> Shipable
</label>
<label class="radio-inline">
<input type="radio" name="approvalstatus" value="1"
@if ((int)Model.PARAMETER.APPROVALSTATUS == 1)
{
checked
}
> Suggestion
</label>
</div>
updated: as Hans suggest you do it as,
<input type="radio" name="approvalstatus" value="4" checked=@((int)Model.PARAMETER.APPROVALSTATUS == 4) required> Shipable
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论