[dancer-users] Trapping parameters from a dynamic list of checkboxes.

Richard Reina gatorreina at gmail.com
Thu Aug 27 18:05:14 BST 2015


That worked! Thank you very much.

Interestingly though $input_hash->{ $key } appears as a hash ref
"HASH(0xa1d2344)" which I was not able to dereference with
%$input_hash->{key}.  This doesn't bother me much because all I really need
to know is that it has value -- that tells me the user checked the box for
this option.

So, instead of looking at the actual value I was just going to do:

    # get parameter for accomp type keys
      foreach my $key ( keys %$Accomps ) {

      if ( param( $key ) ) { # paramter has value
          $input_hash->{ $key } = $Accomps->{ $key };

          # user checked this box. Enter a record into TO_DO table

      }
      }

Is that okay? Or would such an un-exact way of doing it have a downside?

2015-08-27 11:24 GMT-05:00 Yitzchak Scott-Thoennes <sthoenna at gmail.com>:

> The symbolic reference there is $key; you are (unintentionally, I'd
> guess) using print's:
>
>     print FILEHANDLE LIST
>
> syntax, and it is trying to use $key as the filehandle.
>
> Maybe you meant:
>
>     print $key, $input_hash->{ $key }, "\n"
>
> On Thu, Aug 27, 2015 at 8:42 AM, Richard Reina <gatorreina at gmail.com>
> wrote:
> > Hi WK,
> >
> > Thanks for the reply. Line 577 is the print statement  print $key
> > $input_hash->{ $key } . "\n"; In the foreach. I know I shouldn't be
> printing
> > here however, I just want to see what value comes across for for example
> > $input_hash->{ '13' } before I create a DB record based on that value.So
> I
> > guess I just need help figuring out how to see or get the value out of
> > $input_hash->{ID NUMBER}.
> >
> >
> >
> > 2015-08-27 10:07 GMT-05:00 WK <wanradt at gmail.com>:
> >>
> >> 2015-08-27 17:28 GMT+03:00 Richard Reina <gatorreina at gmail.com>:
> >>
> >> > After figuring out how to accommodate my placeholder in
> >> > selectall_hashref I
> >> > did this:
> >> >
> >> >  my $Accomps = $dbh->selectall_hashref( $q, 'ID', \%attr, $Sid );
> >>
> >> If you need placeholder here, but you don't have need for any
> >> attributes, you may use `undef` here
> >>
> >> my $Accomps = $dbh->selectall_hashref( $q, 'ID', undef, $Sid );
> >>
> >> > Then as you suggested I do:
> >> >
> >> >  # get parameter for accomp type keys
> >> >       foreach my $key ( keys %$Accomps ) {
> >> >       print "Checking: " . $key . " for value.\n";
> >> >       if ( param( $key ) ) {
> >> >           $input_hash->{ $key } = $Accomps->{ $key };
> >> >           print $key $input_hash->{ $key } . "\n";
> >> >       }
> >> >       }
> >> >
> >> > (just printing temporarily to see if it trapped the values)
> >>
> >> Here we actually don't need values of $Accomps-hashref, we just using
> >> it as list to check out form values, so depending of your futher
> >> needs, you may assign your specific value here, like, for example:
> >>
> >>            $input_hash->{ $key } = 1;
> >>
> >> > However, I get this error:
> >> >
> >> >  Route exception: Can't use string ("1") as a symbol ref while "strict
> >> > refs"
> >> > in use at /home/richard/Dancer2/MyApp/bin/../lib/MyApp.pm line 557.
> >> >
> >> > Any idea what I am doing wrong?
> >>
> >> What is on line 577 of your MyApp.pm?
> >>
> >> Wbr,
> >> --
> >> Kõike hääd,
> >>
> >> Gunnar
> >> _______________________________________________
> >> dancer-users mailing list
> >> dancer-users at dancer.pm
> >> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
> >
> >
> >
> > _______________________________________________
> > dancer-users mailing list
> > dancer-users at dancer.pm
> > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
> >
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150827/e0e7c345/attachment.html>


More information about the dancer-users mailing list