Javascript Function wont submit form..

Posted by Josh K on Stack Overflow See other posts from Stack Overflow or by Josh K
Published on 2010-05-14T15:40:21Z Indexed on 2010/05/14 15:44 UTC
Read the original article Hit count: 148

Filed under:

Here is my function:

function processCheck() {
                    var numberClicked = 0;
                    var frm = document.getElementById('form');
                    for (var i=0; i<form.elements.length; i++) {
                        if (frm.elements[i].checked)
                            numberClicked++;
                    }
                    if(numberClicked != 8) 
                        alert('Must choose 8 Teams');
                    else
                        frm.submit();
                }

My forms name is 'form', here is my input:

echo "<input type='button' name='submit' value='Update' onclick='processCheck()' />";

When i click the button and there is anything but 8 boxes selected it displays the alert, if there is 8 boxes it does nothing (<-- The problem). I have the form action set to another page.

© Stack Overflow or respective owner

Related posts about JavaScript