Mailing List Archive

help displaying a select list
I can get a select list to work using the vars @STATE_ABBREVIATIONS,
@STATE_NAMES which are retrieved from %STATES. To retrieve a value from
this hash I would enter:
$STATES{'NY'}{'name'} or $STATES{'NY'}{'code'}...

If I don't care about the list order then the following works fine:

<SELECT NAME="state">
<OPTION VALUE="[+ $STATE_ABBREVIATIONS[$row]
+]">$STATE_NAMES[$row]</OPTION>
</SELECT>

If I attempt to re-oder the state abbreviations the abbreviations are
ordered properly but they, of course, do not correlate to the correct
state.

I attempted to do: $STATES{$STATE_ABBREVIATIONS[$row]} for the list
display name but it came back empty. Can something like this be done by
HTMLEmbperl or do I have to handle this myself?
--
__________________________________________________________
Mr. Erich L. Markert emarkert@pace.edu
Computer Learning Center TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer
Re: help displaying a select list [ In reply to ]
from your own example - don't you need?

$STATES{$STATE_ABBREVIATIONS[$row]}{'name'}

cliff rayman
genwax.com

"Erich L. Markert" wrote:

>
> I attempted to do: $STATES{$STATE_ABBREVIATIONS[$row]} for the list
> display name but it came back empty. Can something like this be done by
> HTMLEmbperl or do I have to handle this myself?
> --
RE: help displaying a select list [ In reply to ]
>
> I can get a select list to work using the vars @STATE_ABBREVIATIONS,
> @STATE_NAMES which are retrieved from %STATES. To retrieve a value from
> this hash I would enter:
> $STATES{'NY'}{'name'} or $STATES{'NY'}{'code'}...
>
> If I don't care about the list order then the following works fine:
>
> <SELECT NAME="state">
> <OPTION VALUE="[+ $STATE_ABBREVIATIONS[$row]
> +]">$STATE_NAMES[$row]</OPTION>
> </SELECT>
>
> If I attempt to re-oder the state abbreviations the abbreviations are
> ordered properly but they, of course, do not correlate to the correct
> state.
>
> I attempted to do: $STATES{$STATE_ABBREVIATIONS[$row]} for the list
> display name but it came back empty.

Should work as long as $STATES{$STATE_ABBREVIATIONS[$row]} doesn't return
undef

Shouldn't it be $STATES{$STATE_ABBREVIATIONS[$row]}{name} ?


> Can something like this be done by
> HTMLEmbperl or do I have to handle this myself?

Here is what I would do

[- @STATE_ABBREVIATIONS = sort keys %STATES -]
<SELECT NAME="state">
<OPTION VALUE="[+ $abr=$STATE_ABBREVIATIONS[$row]+]">[+
$STATES{$abr}{name}+]</OPTION>
</SELECT>

Gerald
Re: help displaying a select list [ In reply to ]
Gerald Richter wrote:
Yeah, it was a typo...

> Shouldn't it be $STATES{$STATE_ABBREVIATIONS[$row]}{name} ?
>
> [- @STATE_ABBREVIATIONS = sort keys %STATES -]
> <SELECT NAME="state">
> <OPTION VALUE="[+ $abr=$STATE_ABBREVIATIONS[$row]+]">[+
> $STATES{$abr}{name}+]</OPTION>
> </SELECT>

Works like a champ! Thanks Gerald.
--
__________________________________________________________
Mr. Erich L. Markert emarkert@pace.edu
Computer Learning Center TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer
Re: help displaying a select list [ In reply to ]
Gerald Richter wrote:
>
> >
> Here is what I would do
>
> [- @STATE_ABBREVIATIONS = sort keys %STATES -]
> <SELECT NAME="state">
> <OPTION VALUE="[+ $abr=$STATE_ABBREVIATIONS[$row]+]">[+
> $STATES{$abr}{name}+]</OPTION>
> </SELECT>

A while ago I was sent this solution to display a complex hash in a
select list.

Works like a champ, however in my web error log I'm getting warnings
about $abr not being previously initialized. I've tried initializing it
by setting it to zero just prior to each select as such:

[- $abr = 0; -]<SELECT.....>.....

but I continue to receive this error. I know it's just a warning but is
there anyway to get rid of this warning?
--
__________________________________________________________
Mr. Erich L. Markert emarkert@pace.edu
Computer Learning Center TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer
RE: help displaying a select list [ In reply to ]
>
> but I continue to receive this error. I know it's just a warning but is
> there anyway to get rid of this warning?

This warning comes from the end of the list. There must be one undefined
element, because that is the one that stops the list. So at the moment there
is no chance to get rid of it.

Gerald


-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------