Simple jobs are usually the ones that provide the problems!
I am scripting a web based questionnaire and need to check the values of the check boxes to ensure that they have all been filled in.


The problem is the radio button name changes in accordance with the question number something like this:
Obviously $qaz is an object of type CGI.


$qaz->radio_group(-name=>$questionNumb, -values=>[EMAIL PROTECTED], -default=>'-');

This line is repeated for each question so the HTML resolves as this (say 1 is the question number):
Note that @labelList has 5 items.


<input type="radio" name="1" value="Never"><br>
...
<input type="radio" name="1" value="Very Often"><br>

This all works very nicely, however, when I want to check if all the radio buttons have been selected I get a problem.
There are approx 10 questions a page, but there are a few pages with 12 and < 10 so I cant simply check if there are 10 controls in the param list -
I have a count of the number of questions each page and am passing that in a hidden control in the form (numOfQuestions).
What sort of works is this:


sub processMain(){
...
$numbQuestions = $qaz->param('numOfQuestions') + 3;
%params = $qaz->Vars;

foreach (keys %params){
        @temp = (@temp, $_);
}
if (scalar(@temp) == $numbQuestions){
                print "Answers all answered";
        }else{
                print "At least one question not answered";
}
...
}

It works nicely if there is an unanswered question, however, as the values come from the previous page, if the number of questions on the current page is different there is a problem.
JavaScript would be a solution to my problem (using -onSubmit) however I am having problems passing the number of questions to the JavaScript function.
I want to process the form to check and save values and then return to display the next page:
...
if(defined(param('submit'))){
&processMain();
}
...
Parse questions list and display questions


Sorry its a bit lengthy, but im scratching my head over this issue and would appreciate some hints to fix my problem.
Mind you, its probably blatantly obvious but in my current caffeine induced stupor nothings obvious.


Thanks,
Lachlan.

_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to