RadioButtonList删除所有内容并使用java脚本重新填充



要使用javascript清除列表框,请执行以下操作

document.getElementById("<%= Listbox.ClientID %>").selectedIndex = -1;
document.getElementById("<%= Listbox.ClientID %>").options.length = 0;

但是要清除RadioButtonList,以下操作不起作用,有办法吗

document.getElementById("<%= RadioButtonList.ClientID %>").selectedIndex = -1;
document.getElementById("<%= RadioButtonList.ClientID %>").options.length = 0;

我需要知道——使用Javascript如何删除RadioButtonList的全部内容并重新填充不同的项目

您可以使用以下代码删除表LawGroupTable 中的完整内容

document.getElementById('LawGroupTable').innerHTML="";

单独移除内部表格:

document.getElementById('RLst_CharGroup').innerHTML="";

你必须像下面那样重新填充

document.getElementById('RLst_CharGroup').innerHTML = '<tbody><tr><td><input name="RLst_CharGroup" id="RLst_CharGroup_0" type="radio" value="a">' + '<label for="RLst_CharGroup_0">1</label></td></tr><tr><td><input name="RLst_CharGroup" id="RLst_CharGroup_1" type="radio" value="b">' + '<label for="RLst_CharGroup_1">2</label></td></tr><tr><td><input name="RLst_CharGroup" id="RLst_CharGroup_2" type="radio" value="c">' + '<label for="RLst_CharGroup_2">3</label></td></tr>';

使用$('.checkboxlistid9').removeAttr('checked');this jQuery取消选中所有单选列表。

在如下javascript中使用removeAttribute

document.getElementById("<%= RadioButtonList.ClientID %>").removeAttribute('checked');

以下是将项目添加到单选按钮列表的渲染的一部分

<table width="100%" align="right" id="LawGroupTable" style="margin-top: -10px; display: none;" bgcolor="#666666">
<tbody>
<tr>
<td>
<table id="RLst_CharGroup">
<tbody>
<tr>
<td>
<input name="RLst_CharGroup" id="RLst_CharGroup_0" type="radio" value="a">
<label for="RLst_CharGroup_0">1</label>
</td>
</tr>
<tr>
<td>
<input name="RLst_CharGroup" id="RLst_CharGroup_1" type="radio" value="b">
<label for="RLst_CharGroup_1">2</label>
</td>
</tr>
<tr>
<td>
<input name="RLst_CharGroup" id="RLst_CharGroup_2" type="radio" value="c">
<label for="RLst_CharGroup_2">3</label>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>

最新更新