Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: HTML::Template with checkbox

by bebewinla (Novice)
on Sep 05, 2012 at 16:03 UTC ( #991885=note: print w/replies, xml ) Need Help??

in reply to Re: HTML::Template with checkbox
in thread HTML::Template with checkbox

I have my cgi script very similar to what you have. hastable contains the filenames to be output it. I don't have the f1,f2...values for the check, not sure if it's needed.

$q = new CGI; $template = HTML::Template->new(filename => "$displaypage", associate => $q); my @loop; foreach $index (sort {$a <=> $b} keys %hashtable) { my ($fn) = @{$hashtable{$index}}; my %row = ( index => $index, fn => $fn , check => " "); push (@loop, \%row); } $template->param(files_loop=> \@loop); send_header(); print $template->output;

so after user click on the checkboxes for the files that he wants to download, then he click on the "download" button, in my cgi script it will go to "sub downloadFiles", in here I am not sure how to get the values of the checkboxes or filenames , I tried this :

sub downloadfiles { @files = $q->param("field"); ... }
It did not get any values in @files. Not sure what values it should returned. I tried you suggestion adding f1,f2 with instead using index number 1,2,3... but still don't know how to get the checkboxes values. Please help.

Replies are listed 'Best First'.
Re^3: HTML::Template with checkbox
by GrandFather (Sage) on Sep 05, 2012 at 23:34 UTC

    Oh, silly me. You don't provide a value attribute for your checkbox so nothing gets returned. You need something like:

    <td><input type="checkbox" name="field" value="<TMPL_VAR NAME="fi +lename">">

    for your checkbox line. That will return the file name if the checkbox is checked.

    True laziness is hard work

      how do you fetch the checkbox value ? I tried using q->param("field") it returns nothing, do you think the associate => $q is wrong when creating new template. should I take it out, but then how do I fetch the checkbox values

      $q = new CGI; $template = HTML::Template->new(filename => "$displaypage", associate => $q);

        Hope you got the answer by this time now

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991885]
[stevieb]: I really dislike how perlbrew doesn't list your version of perl if a newer minor version bump has happened. eg: I use 5.24.1, but 5.24.2 is available, hiding my 5.24.1. I may look at this, as I made it display correctly in berrybrew in cases like this
[stevieb]: choroba just gleaned your post about Module::Starter. I use it too, pretty much for every dist I write
[LanX]: I remeber M::S (it was dialog driven?) to be buggy
[stevieb]: As far as Dist::Zilla goes, I don't like installing that other than on systems my test platorm runs on. I find it too heavy. I prefer being able to glean a Makefile.PL

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2017-08-18 20:50 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (310 votes). Check out past polls.