Javascript and only one Checkbox - undefined

后端 未结 8 1192
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-18 11:11
for (i = 0; i < document.checks.user.length; i++) //for all check boxes
{
    if (document.checks.user[i].checked == true )
    {
        document.checks.submit()         


        
相关标签:
8条回答
  • 2021-01-18 12:01

    Use a loop control variable, and set it to 1 if length is undefined...

    var len = document.checks.user.length;
    if(len == undefined) len = 1;
    for (i = 0; i < len; i++) //for all check boxes
    

    Best regards...

    0 讨论(0)
  • 2021-01-18 12:04

    jQuery is your friend:

    $("input[type='checkbox']").attr('checked', false);
    

    (... if jQuery is available to you?)

    0 讨论(0)
提交回复
热议问题