RadioButtonListで構成される簡単な検証を試みていますrblstPallet
。私は以下のコードを試しました:
javascript
var rblstPallet = document.getElementById('rblstPallet');
var counter = 0;
for (var intCount = 0; intCount < rblstPallet.length; intCount++) {
if (rblstPallet[intCount].checked) { //this step is not working
console.log(intCount); //I checked using this step
counter++;
}
}
if (counter == 0) {
//MSG: please select any item
}
else {
// Redirect to next page function
}
.aspx
<asp:RadioButtonList ID="rblstPallet" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>Wood</asp:ListItem>
<asp:ListItem>Plastic</asp:ListItem>
<asp:ListItem>None</asp:ListItem>
</asp:RadioButtonList>
問題は、ラジオボタンの1つを選択しても、counter
値が同じままであるということです。コードをデバッグしたとき、その行が
if(rblstPallet [intCount] .checked){
実行されておらず、コンソールにエラーも表示されていません。私はこのリンクを通過しています。このリンクを試しました(機能していません)。
助けてください。