单选按钮的行为有些奇怪,如随附的GIF中所示。
当我单击标签时,选定的值将被清除,单选按钮将变为空,且未选中任何值
我找不到问题的原因。
我只是使用基本的单选按钮
`
<tr>
<td style="padding-left: 15px">@Html.Raw(Dashboard.ResourcesLanguage.Language.admin)</td>
<td class="Admin-class"></td>
<td><input class="checkbox" type="radio" id="radioYes" name="radioAdmin" value="Yes" /><label for="radioYes">@Html.Raw(Dashboard.ResourcesLanguage.Language.yes)</label></td>
<td><input class="checkbox" type="radio" id="radioNo" name="radioAdmin" value="No" checked /><label for="radioNo">@Html.Raw(Dashboard.ResourcesLanguage.Language.no)</label></td>
<td><input class="checkbox" type="checkbox" id="error-log" name="ErrorLog" disabled>@Html.Raw(Dashboard.ResourcesLanguage.Language.errorLog)</td>
</tr>
<tr>
<td style="padding-left: 15px">@Html.Raw(Dashboard.ResourcesLanguage.Language.auditor)</td>
<td class="Auditor-class"></td>
<td><input class="checkbox" type="radio" id="radioYesAudit" name="radioAuditor" value="Yes" /><label for="radioYes">@Html.Raw(Dashboard.ResourcesLanguage.Language.yes)</label></td>
<td><input class="checkbox" type="radio" id="radioNoAudit" name="radioAuditor" value="No" checked /><label for="radioNo">@Html.Raw(Dashboard.ResourcesLanguage.Language.no)</label></td>
</tr>
答案 0 :(得分:2)
您在复选框下方的单选按钮中使用了相同的label for
。应该是
<input class="checkbox" type="radio" id="radioYesAudit" name="radioAuditor" value="Yes" />
<label for="radioYesAudit">@Html.Raw(Dashboard.ResourcesLanguage.Language.yes)</label>
现在不一样
<input class="checkbox" type="radio" id="radioYesAudit" name="radioAuditor" value="Yes" />
<label for="radioYes">@Html.Raw(Dashboard.ResourcesLanguage.Language.yes)</label>
与radioNoAudit
单选按钮相同
答案 1 :(得分:-1)
问题是您的Radio标签为YES,所以这就是为什么您未在正确的位置看到单选按钮的原因。
<td><input class="checkbox" type="radio" id="radioYesAudit" name="radioAuditor" value="Yes" /><label for="radioYesAudit">@Html.Raw(Dashboard.ResourcesLanguage.Language.yes)</label></td>
<td><input class="checkbox" type="radio" id="radioNoAudit" name="radioAuditor" value="No" checked /><label for="radioNoAudit">@Html.Raw(Dashboard.ResourcesLanguage.Language.no)</label></td>