As is often the case, that's led me on to a new problem...
This is my javascript code:
function validate()
{
var totalgol = 0;
var maxgol = document.forms[0].elements['goalkeeper[]'].length;
for (var idx = 0; idx < maxgol; idx++)
{
if (eval("document.forms[0].elements['goalkeeper[" + idx + "]'].checked") == true)
{
totalgol += 1;
}
}
if (totalgol != 1)
{
alert ("Please choose a goalkeeper");
return false;
}
return true;
}
And this is my form:
<form action="new_pick2.php" name="pickateam" method="post" onsubmit="return validate();">
<input type="checkbox" name="goalkeeper[]" id="gol1" onClick="countGol(this)" value="Dida" />Dida (AC Milan)<br />
<input type="checkbox" name="goalkeeper[]" id="gol2" onClick="countGol(this)" value="Julio Cesar" />Julio Cesar (Flamengo)
</form>
But when I sumbit the form I get a Javascript error:
Error: document.forms[0].elements['goalkeeper[0]'] has no properties
And the value is passed into the next page as the word 'Array'.
Sorry, I know this is more Javascript than PHP, but it's combining the two that's killing me.