[cgiapp] cgiapp Digest, Vol 31, Issue 11

Perlhispano webmaster at perlhispano.com
Thu Apr 15 12:14:48 EDT 2010


You can use FormBuilder for that

--------------------------------------------------
From: <cgiapp-request at lists.openlib.org>
Sent: Thursday, April 15, 2010 11:00 AM
To: <cgiapp at lists.openlib.org>
Subject: cgiapp Digest, Vol 31, Issue 11

> Send cgiapp mailing list submissions to
> cgiapp at lists.openlib.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.openlib.org/mailman/listinfo/cgiapp
> or, via email, send a message with subject or body 'help' to
> cgiapp-request at lists.openlib.org
>
> You can reach the person managing the list at
> cgiapp-owner at lists.openlib.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of cgiapp digest..."
>
>
> Today's Topics:
>
>   1. Dropdown Menu (Adam)
>   2. Re: Dropdown Menu (Michael Peters)
>   3. Re: Dropdown Menu (Mark Fuller)
>   4. Re: Dropdown Menu (Mike Tonks)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 14 Apr 2010 15:52:21 -0600
> From: Adam <adam at spatialsystems.org>
> Subject: [cgiapp] Dropdown Menu
> To: cgiapp at lists.openlib.org
> Message-ID:
> <n2t3326cb781004141452y9b759000z934e2ea8cf564e41 at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I want to have a dropdown menu that shows years 2000 thru 2015.  I'm using
> HTML::Template and I know I can pass an array ref to HTML::Template and 
> loop
> over it to make the menu, but how would I put in a "selected" year? 
> What's
> the best method?
>
> The selected year would be decided at runtime.
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 14 Apr 2010 18:06:40 -0400
> From: Michael Peters <mpeters at plusthree.com>
> Subject: Re: [cgiapp] Dropdown Menu
> To: CGI Application <cgiapp at lists.openlib.org>
> Message-ID: <4BC63C70.4030109 at plusthree.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> On 04/14/2010 05:52 PM, Adam wrote:
>> I want to have a dropdown menu that shows years 2000 thru 2015.  I'm 
>> using
>> HTML::Template and I know I can pass an array ref to HTML::Template and 
>> loop
>> over it to make the menu, but how would I put in a "selected" year? 
>> What's
>> the best method?
>
> For form filling, look at HTML::FillInForm. It's really fast and very
> flexible. I was amazed at how much complexity it removes from
> applications and templates.
>
> -- 
> Michael Peters
> Plus Three, LP
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 14 Apr 2010 15:52:16 -0700
> From: Mark Fuller <azfuller at gmail.com>
> Subject: Re: [cgiapp] Dropdown Menu
> To: CGI Application <cgiapp at lists.openlib.org>
> Message-ID:
> <q2sd69cc4a61004141552o6fd0f384nd2fd5a0cf9c9451c at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Wed, Apr 14, 2010 at 2:52 PM, Adam <adam at spatialsystems.org> wrote:
>> I want to have a dropdown menu that shows years 2000 thru 2015. ?I'm 
>> using
>> HTML::Template and I know I can pass an array ref to HTML::Template and 
>> loop
>> over it to make the menu, but how would I put in a "selected" year? 
>> ?What's
>> the best method?
>
> I struggled with this when I first began using H::T. You need to add a
> "selected" hash item to the array ref. As you build the array ref, you
> have to ask "if current-year equal form-year, set selected = 1."
>
> Then, in your template you have to put inside the tmpl-loop, a
>
>    <option <tmpl-if name=selected>
> selected="selected"</tmpl-if>><tmpl-var name=value></option>
>
> (I may have made a few typos in that example.).
>
> I thought this was unintuitive compared to how intuitive C::A and H::T
> are. It seemed like there should be a better way. But, after I got
> used to it, I obsessed about bigger and better things.
>
> I've never used fillnform. That might be a good suggestion. But, I
> wanted to make sure you know how to do it naively.
>
> Mark
>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 15 Apr 2010 09:28:22 +0100
> From: Mike Tonks <fluffymike at googlemail.com>
> Subject: Re: [cgiapp] Dropdown Menu
> To: CGI Application <cgiapp at lists.openlib.org>
> Message-ID:
> <i2s727692631004150128ieb162376j218f68989171fba0 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> I find it works pretty well using TMPL_LOOP and an array of hashref's
> from the db - I loop through the data array and set the 'Selected'
> item before passing into the template, like so:
>
> in the viewer module:
>
> my $product_types = $self->dbh->selectall_arrayref("select * from
> product_type where ONIX_Code like 'B%'", { Slice => {} });
>
> if ($data->{ProductTypeID}) {
> foreach my $row (@$product_types) {
> $row->{Selected} = 'selected' if $row->{ProductTypeID} eq
> $data->{ProductTypeID};
> }
> }
>
> $template->params(product_types => $product_types);
>
> in the template:
>
> <select class="inputbox" name="ProductTypeID">
> <TMPL_LOOP NAME="product_types">
> <option value="<TMPL_VAR NAME="ProductTypeID">" <TMPL_VAR
> NAME="Selected">><TMPL_VAR NAME="ONIX_Code"> : <TMPL_VAR
> NAME="ProductType"></option>
> </TMPL_LOOP>
> </select>
> <TMPL_VAR NAME="err_ProductTypeID">
>
> mike
>
> On 14 April 2010 22:52, Adam <adam at spatialsystems.org> wrote:
>> I want to have a dropdown menu that shows years 2000 thru 2015. ?I'm 
>> using
>> HTML::Template and I know I can pass an array ref to HTML::Template and 
>> loop
>> over it to make the menu, but how would I put in a "selected" year? 
>> ?What's
>> the best method?
>
>
> ------------------------------
>
> _______________________________________________
> cgiapp mailing list
> cgiapp at lists.openlib.org
> http://lists.openlib.org/mailman/listinfo/cgiapp
>
>
> End of cgiapp Digest, Vol 31, Issue 11
> ************************************** 



More information about the cgiapp mailing list