"Todd Wade" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

----- Original Message -----
From: "Jack Daly" <[EMAIL PROTECTED]>
To: "Todd Wade" <[EMAIL PROTECTED]>
Sent: Sunday, April 21, 2002 11:51 PM
Subject: Re: popup_menu default


> On Sun, 21 Apr 2002, Todd Wade wrote:
>
> >
> > "Jack Daly" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > >
> > early on in the doc is says if you import the functions you can despense
> > with the $query-> (oop) part of the syntax. Then it says:

reread what is says right there

> I gave it a shot and replaced my line with:
>
> print $query->popup_menu('menu_name', ['eenie','meenie','minie'],
> 'meenie',\%labels);

You used the $query-> part of the syntax, exactly what I said you could
despense with above

> Use strict complained so i added my $query and my %labels, didn't work.
> Then I dropped the %labels as i understand that to be optional. here's the
> error message:

Explain why you understand this to be optional. You are correct, but prove
to me you are correct.

>   Can't call method "popup_menu" on an undefined value at
> /htdocs/j/d/jddaly/cgi-bin/delete.pl line 61, <AFILE> chunk 150.
>

Of course. You never defined $query in your program.

More from the docs, right below the information I quoted to you earlier:

The optional third parameter (-default) is the name of the default menu
choice. If not specified, the first item will be the default. The values of
the previous choice will be maintained across queries.

Do you understand what a parameter is? You are going to have a hard time
writing cgi programs if you are missing some fundamental concepts of
programming (a "parameter" has nothing to do with perl per se. A parameter
list is a fundamental concept in any type of programming or mathematics. Say
you define f(x) = x + 2. Then f(1) = 1 + 2, right? 1 is the first and only
parameter to f(). Just like the third parameter to popup_menu() is the item
to be selected by default. Theres definitely no magic to function
parameters.

Here is the code you are looking for:

#!/usr/bin/perl -w

use strict;
use CGI qw/:standard/;

my($who) = 'Todd';
my(@FILE) = qw(apples oranges banannas grapes);
print start_html();
### start your code ####
print p ("Select from the pull-down menu.");
print start_form();
print p(textfield ("name", $who));
print p(submit ("Delete" ), popup_menu ("value", \@FILE, 'banannas'));
### end your code ######
print end_form(), end_html();

notice the extra argument to popup_menu is the only thing different inside
the start and end comments is the extra argument to popup_menu, the item to
be selected by default on the input field in the form.

Dont ever apologize for not understanding something. You are just trying to
use a feature of the language that you are not ready to use. But there is a
problem...next time you run in to something like this, youre going to be
back in the newsgroup asking the same question because you didnt learn
anything from me telling you the answer. Go get the learing perl book, start
from page 1 sitting at your computer, and type in every example it shows and
do every exercise. You are going to make mistakes, and thats how you learn
the syntax of the language.

Another thing, dont say, "How do I get it to work?".... Explain your
reasoning, citing the documentation, of what point you made it up to, and
where you got stuck. 9.999 times out of 10, you will end up answering the
question yourself as you compose your message.

trwww




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

Reply via email to