如何获取radiobutton列表行长度/列重复水平模式

时间:2017-06-29 12:03:57

标签: javascript c# jquery asp.net

我的radiobutton列表有三个值,当我重复它时,它给出的行长度为3,但是当我重复单选按钮列表时,它将行长度设为1。

var radiosub = document.getElementById('ContentPlaceHolder1_JewelleryServices_dtbindjewellery_radiosub_' + i);

if (radiosub != null) {                                                                  
  var radiosubcount = radiosub.rows.length;
  alert(radiosubcount);  
}  

我的视图页面源布局

<table id="ContentPlaceHolder1_JewelleryServices_dtbindjewellery_radiosub_3" class="spaced">
            <tbody><tr>
                <td><input id="ContentPlaceHolder1_JewelleryServices_dtbindjewellery_radiosub_3_0_3" type="radio" name="ctl00$ContentPlaceHolder1$JewelleryServices$dtbindjewellery$ctl03$radiosub" value="7"><label for="ContentPlaceHolder1_JewelleryServices_dtbindjewellery_radiosub_3_0_3">Yellow Gold</label></td>
               <td><input id="ContentPlaceHolder1_JewelleryServices_dtbindjewellery_radiosub_3_1_3" type="radio" name="ctl00$ContentPlaceHolder1$JewelleryServices$dtbindjewellery$ctl03$radiosub" value="8"><label for="ContentPlaceHolder1_JewelleryServices_dtbindjewellery_radiosub_3_1_3">Rhodium White Gold</label></td>
               <td><input id="ContentPlaceHolder1_JewelleryServices_dtbindjewellery_radiosub_3_2_3" type="radio" name="ctl00$ContentPlaceHolder1$JewelleryServices$dtbindjewellery$ctl03$radiosub" value="9"><label for="ContentPlaceHolder1_JewelleryServices_dtbindjewellery_radiosub_3_2_3">Rose Gold</label></td>
            </tr>
        </tbody></table>

当我重复单选按钮

时,如何将数量计为3?

1 个答案:

答案 0 :(得分:0)

如果要计算水平无线电输入,可以使用此代码查找计数/长度

document.getElementById("ContentPlaceHolder1_JewelleryServices_dtbindjewellery_radiosub_3").rows[0].cells.length;  // this will return the length of the cell from first row of the tabl. If you want to count the succeeding row column, you have to change the array index as 1,2...