DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Validation with js of two dimensional array (http://www.daniweb.com/forums/thread65388.html)

kaa_ Dec 20th, 2006 11:41 am
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]<form action="thx.php" method=POST name=form onSubmit="return check(this)">[/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 :)

MattEvans Dec 20th, 2006 10:37 pm
Re: Validation with js of two dimensional array
 
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?


All times are GMT -4. The time now is 6:49 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC