Thanks Sibu. But the problems is that even the names of the checkboxes and radio buttons are going to be dynamic. I really can't hard code any names like this. Thanks. --Alex
> Hi, > We use something like following at the Perl level to check for radio > button > and check boxes that are not passed from HTML form. > > #---------------------------------- > > # At CGI save level, receive all the params using CGI object. > > my $cgi = $self->query(); > my @array = $cgi->param; > > # Make a key value pair of normal HTML elements from form and also extract > checkbox group and multi-list selection box > # values in to a single comma separated value. > > my %form = map { $_ => scalar @{[ $cgi->param( $_ ) ]} == 1 ? $cgi->param( > $_ ) : join(",", $cgi->param( $_ ) ) } @array; > > my $form = setHTMLTagValues(\%form}; > > foreach (sort keys %$form) > { > # Save to database or do whatever you want to do..... > } > > #---------------------------------- > > > sub setHTMLTagValues > { > my $hash = shift; > > # You can add different profiles for each forms used here. > > my @array = ('Radio1','Radio2','Check1'); > > # Set any value so that the script finds the name of the missing > HTML tag while processing. > > map{ $hash->[EMAIL PROTECTED] = '' if(!exists( $hash->{$_} )); } @array; > > return($hash); > } > > HTH > Thanks > > Sibu Thomas > Liaison Inernational Inc > Watertown, MA > > > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of Alex Brelsfoard > Sent: Thursday, May 26, 2005 10:56 AM > To: Joel Gwynn > Cc: boston-pm@mail.pm.org > Subject: Re: [Boston.pm] Empty radio and checkboxes not passed to perl scr > ipt > >> Forgive my ignorance, but why would it be a problem not to have these? >> > > Picture a web form that is some sort of a survey. When that survey is > submit the perl script writes out the answers onto a file. That file is > tab > delimited. > Now picture the first person going to the form and filling everything out, > including all checkboxes and radio buttons. > Now the second person comes along and chooses not to fill in a radio > button. > When that form's information is sent to the script it is missing that > radio > buttons field name and therefore misses that tab, and all the results get > skewed. Information becomes invalid, people get unhappy, heads are lost, > cats and dogs start getting married, and all the worlds wine turns into > bags > of turnips. > In other words, not terribly fun. > --Alex > >> On 5/26/05, Philipp Hanes <[EMAIL PROTECTED]> wrote: >>> > The following ideas are options I would _not_ like to follow if >>> > possible: >>> > - set a default checkbox or redio button (so something is always >>> > filled in). >>> > - use a hidden field to list of all the fields in the form. >>> > - have the perl script read the HTML code from the page and make >>> > its own list. >>> > - javascript >>> > >>> > I kinda understand why the browser doesn't send this information >>> > (no value to hold onto), but there HAS to be a solution for this. >>> > Seems frightfully >>> > stupid not to have an easy option out there for something like this. >>> >>> No solution other than the ones you mentioned, that I'm aware of. >>> What we've done is generally a hidden field that gets fiddled with >>> via JavaScript when the checkbox is changed. Then the back-end code >>> just looks at the hidden field, and can be totally oblivious to >>> what's really going on in the HTML. >>> Yup, seems stupid to me, each time I run into it again, too. >>> I'd be curious if someone has come up with something better. >>> Doubtful, though. >>> good luck philipp >>> >>> _______________________________________________ >>> Boston-pm mailing list >>> Boston-pm@mail.pm.org >>> http://mail.pm.org/mailman/listinfo/boston-pm >>> >> >> _______________________________________________ >> Boston-pm mailing list >> Boston-pm@mail.pm.org >> http://mail.pm.org/mailman/listinfo/boston-pm >> > > > _______________________________________________ > Boston-pm mailing list > Boston-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/boston-pm > _______________________________________________ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm