nmerriweather has asked for the wisdom of the Perl Monks concerning the following question:
i'm working out the validation of select boxes right now -- I want only the selectbox options to be valid.my $form = new FormObject( $ref2QuestionsHash, $ref2QuestionsOrderArra +y ); $form->printForm; $form->validate($ref2UserInput)
That would result in html of : _option value="m"_ male _/option_ -- and an f/female'data' => [ ['m','male'], ['f','female'], ],
So, my question is - anyone have a better idea? The only other option I considered was creating a hash of acceptable answers and checking existance -- but to accomplish that I'd either have to pre-compute the hash keys, which saves me looping at the expense of memory, OR i'd loop through it realtime to make the hash -- which this method does already without the added step of checking the hashmy $valid = 0; for (my $i=0; $i<=$#{$question->{'data'}};$i++){ if ( $answer eq ${$question->{'data'}}[$i][0] ) { $valid = 1; last; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: web form processing - efficiency question
by blokhead (Monsignor) on May 07, 2004 at 00:26 UTC | |
by nmerriweather (Friar) on May 07, 2004 at 01:10 UTC | |
by knoebi (Friar) on May 07, 2004 at 08:24 UTC | |
by nmerriweather (Friar) on May 07, 2004 at 18:27 UTC |