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.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to