954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Validation with js of two dimensional array

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.


[html][/html]

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

function check(form) {


    a=0;
    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 :)

kaa_
Newbie Poster
1 post since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

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?

MattEvans
Veteran Poster
Moderator
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You