You can use FormBuilder for that -------------------------------------------------- From: <cgiapp-requ...@lists.erlbaum.net> Sent: Thursday, April 15, 2010 11:00 AM To: <cgiapp@lists.erlbaum.net> Subject: cgiapp Digest, Vol 31, Issue 11
> Send cgiapp mailing list submissions to > cgiapp@lists.erlbaum.net > > To subscribe or unsubscribe via the World Wide Web, visit > http://www.erlbaum.net/mailman/listinfo/cgiapp > or, via email, send a message with subject or body 'help' to > cgiapp-requ...@lists.erlbaum.net > > You can reach the person managing the list at > cgiapp-ow...@lists.erlbaum.net > > 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 <a...@spatialsystems.org> > Subject: [cgiapp] Dropdown Menu > To: cgiapp@lists.erlbaum.net > Message-ID: > <n2t3326cb781004141452y9b759000z934e2ea8cf564...@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 <mpet...@plusthree.com> > Subject: Re: [cgiapp] Dropdown Menu > To: CGI Application <cgiapp@lists.erlbaum.net> > Message-ID: <4bc63c70.4030...@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 <azful...@gmail.com> > Subject: Re: [cgiapp] Dropdown Menu > To: CGI Application <cgiapp@lists.erlbaum.net> > Message-ID: > <q2sd69cc4a61004141552o6fd0f384nd2fd5a0cf9c94...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Wed, Apr 14, 2010 at 2:52 PM, Adam <a...@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 <fluffym...@googlemail.com> > Subject: Re: [cgiapp] Dropdown Menu > To: CGI Application <cgiapp@lists.erlbaum.net> > Message-ID: > <i2s727692631004150128ieb162376j218f68989171f...@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 <a...@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@lists.erlbaum.net > http://www.erlbaum.net/mailman/listinfo/cgiapp > > > End of cgiapp Digest, Vol 31, Issue 11 > ************************************** ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################