User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,906 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,583 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2523 | Replies: 1
Reply
Join Date: Dec 2006
Posts: 1
Reputation: kaa_ is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kaa_ kaa_ is offline Offline
Newbie Poster

Validation with js of two dimensional array

  #1  
Dec 20th, 2006
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 47
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is online now Online
Posting Shark

Re: Validation with js of two dimensional array

  #2  
Dec 20th, 2006
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?
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:39 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC