In html i have some question, and the answers are radio buttons ...
the names of variables in html are array ... like question[1], question[2] ... etc.
and every question has multiple value, depending of the answer.

<form action="thx.php" method=POST name=form onSubmit="return check(this)">

In javascript i have to determinate if the question is answered, if it is not then return false ...

function check(form) {

    for (i=0;i<form.question[1].length;i++){
    if (form.question[1][i].checked===true)  {a=1;}
    if (a==0) {
    alert("question[1] no.1: You didn't answer the question");
    return false;

Everything work fine until i changed my variables into arrays.
What is wrong now?
How javascript handle two dimensional array?

pls help :)

11 Years
Discussion Span
Last Post by MattEvans

O_o maybe javascript doesn't do what you think it does... or maybe that's too incomplete a code snippet to see what your trying to do. forms.question[1] doesn't look like a DOM object reference.. and it wont neccessarily relate to any input element(s) on your HTML page...

what is the HTML code you are using?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.