--- Gerry Jones <[EMAIL PROTECTED]> wrote:
> On Thursday 01 November 2001 02:06, you wrote:
> > I am attempting to use the DEFAULT parameter within a popup_menu to set
> the
> > displayed value to what I want based on the passed parameters in the
> URL.
> > I am using Mozilla 0.9.4 on a Linux machine, and hope that isn't the
> reason
> > I'm not seing what I want to see. Here is the code:
> >
> > ----CODE----
> > #!/usr/bin/perl -w
> >
> > use CGI qw(:standard);
> >
> > print header, start_html("cgi_pm_test.cgi");
> > print popup_menu(
> > -NAME => "baths",
> > -VALUES => ["0", "1", "1 1/2", "2"],
> > -LABELS => {
> > 0 => "?????",
> > 1 => "1",
> > "1 1/2" => "1 1/2",
> > 2 => "2",
> > }
> > -DEFAULT => 1,
> > );
> > print end_html;
> > ----END CODE----
> > Any thoughts out there? Thanx.
>
> I'm no pro, but I was just doing what you want the other day, so here
> goes...
>
> You shouldn't use quotes - instead use apostrophe's, there is probably a
> reason why, but I can't remember. Also, you can't use a -LABELS part.
> Read
> the CGI.pm docs to see what you can use with functions. Your code should
> look
> like this:
>
> #!/usr/bin/perl -w
>
> use CGI qw/:standard/;
> use CGI::Carp qw/fatalsToBrowser/; # use for debugging - delete when
> finished
>
> print header, start_html("cgi_pm_test.cgi");
> print start_form();
> print popup_menu(
> -name=>'baths',
> -value=>['0', '1', '1 1/2', '2']
> -default=>'1'
> );
> print end_form();
> print end_html();
>
> If you want to change the values depending on what is passed, then that
> is a
> little more complicated. You would have to use the param() function to
> get
> the passed value and set a variable to the default value i.e.
>
> .......
> -default=>$x
> .......
>
> Hope this helps,
>
> Gerry.
>
---DIFFERENT REPLY INCLUDED---
> #!/usr/bin/perl -w
> # mytest.cgi
> use strict;
> use CGI 2.78 qw/:standard :html3 -no_xhtml/;
> use CGI::Pretty qw/:html3/;
>
> my %labels = (
> '0' => '?????',
> '1' => '1',
> '1 1/2' => '1 1/2',
> '2' => '2'
> );
> print header(), start_html("cgi_pm_test.cgi"),
> start_form(),
> popup_menu(-name=>'baths', -Values=>\%labels, -default=>'1'),
> submit(-name=>'submit', -Value=>'Click Me'),
> end_form(),
> end_html;
>
> the following output gets produced:
>
> Content-Type: text/html; charset=ISO-8859-1
>
> <!DOCTYPE html
> PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html lang="en-US"><head><title>cgi_pm_test.cgi</title>
> </head><body>
> <form method="post" action="mytest.cgi"
> enctype="application/x-www-form-urlencoded">
> <select name="baths">
> <option value="0">?????</option>
> <option selected="1" value="1">1</option>
> <option value="2">2</option>
> <option value="1 1/2">1 1/2</option>
> </select><input type="submit" name="submit" value="Click
> Me"></form></body></html>
>
> note the capital V in Value and Values in the script above.
> see cgi_docs.html for details (comes with CGI.pm when you download from
> CPAN)
>
> --
> Scott R. Godin | e-mail : [EMAIL PROTECTED]
The code (both this and after some minor adjustments) produced the proper
HTML (proved by viewing doc src). But doesn't display the default item
w/in the box. I added a scrolling_list and an HTML coded "popup_menu" and
both of those displayed properly. I will attempt to use the above two
codes and see any possible varience in resulting HTML. I'll update evryone
tonight. Thanks for your assitance.
--Alan
=====
Alan F. Larimer, Jr.
http://www.geocities.com/lrng_lnx/
Build a man a fire, he will be warm for a day;
Set a man on fire, he will be warm for the rest of his life.
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]