开发者

I am using repeater to display data from database and using checkboxes.But I am not getting values of multiple selected checkboxes..please help

<script type="text/javascript">
            function collect() {
                alert('in function');
                var adds = new Array();
                alert(adds);
        for (var i = 0; i < control.getElementByName("box").value; i++) {
            alert('innn function');
            if (control.getElementByName("box[i]").checked)
                adds = control.getElementByName("box[i]").value;
        }
        alret(adds);
        //window.location="/collect.aspx?value="+adds;
        control.getElementByN开发者_运维知识库ame("Label1").appendChild(adds);

        } 
</script>

calling function on button:

  <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" OnClientClick="collect() "/>


Try changing

for (var i = 0; i < control.getElementByName("box").value; i++) {
   alert('innn function');
   if (control.getElementByName("box[i]").checked)
   adds = control.getElementByName("box[i]").value;
}

To:

for (var i = 0; i < control.getElementByName("box").value; i++) {
   alert('innn function');
   if (control.getElementByName("box[" + i + "]").checked)
   adds = control.getElementByName("box[" + i + "]").value;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜