Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am selecting more than one option in the select box and retrieving in the submit page as
my $userID = param('users');
This works fine for if I select only one option.
If I select more than one then I can only see first option.
What could be reason.Please advise
Thanks
Blazix

Replies are listed 'Best First'.
Re: Select Box Options
by insensate (Hermit) on Aug 13, 2004 at 17:54 UTC
    Your select box options can be retrieved in array context. Try:
    my @choices=param('selectbox'); print join ' ', @choices;
Re: Select Box Options
by Mr_Jon (Monk) on Aug 13, 2004 at 17:55 UTC
    You need to call param in list context:

    my @userIDs = $query->param('users')

    See the CGI docs for more info.
Re: Select Box Options
by wfsp (Abbot) on Aug 13, 2004 at 17:57 UTC
    From cgi.pm doc:
    @values = $query->param('foo'); -or- $value = $query->param('foo');
    Pass the param() method a single argument to fetch the value of the named parameter. If the parameter is multivalued (e.g. from multiple selections in a scrolling list), you can ask to receive an array. Otherwise the method will return a single value.