Mailing List Archive

select list question - again...
If I have the following in a form:

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

I have a routine that restores %fdat to the stored data values in the DB
so users can come back and edit a form, but I can't figure out how to
get select lists restored.

I tried the following:

<OPTION VALUE="[+ $abr=$STATE_ABBREVIATIONS[$row]+]"[$ if( (defined
$fdat{'state'})
&& ($fdat{'state'} eq $abr) )$] SELECT[$ endif $]>

but this doesn't reset "state" to the value that was retrieved from the
database.
--
__________________________________________________________
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: select list question - again... [ In reply to ]
> I have a routine that restores %fdat to the stored data values in the DB
> so users can come back and edit a form, but I can't figure out how to
> get select lists restored.
>
> I tried the following:
>
> <OPTION VALUE="[+ $abr=$STATE_ABBREVIATIONS[$row]+]"[.$ if( (defined
> $fdat{'state'})
> && ($fdat{'state'} eq $abr) )$] SELECT[$ endif $]>
>
> but this doesn't reset "state" to the value that was retrieved from the
> database.

Must be "SELECTED" and not SELECT, but it should be enought to simply set
%fdat to the same values as it was before and Embperl will automaticly
insert the SELECETED attribut to your OPTION tags.

Gerald
Re: select list question - again... [ In reply to ]
Another typo on my part in my example... I had selected in my actual
code but anyway...

I found out what the problem was. The lookup values used in the select
list were uppercase, the retrieved values from the database were
lowercase. Restoring %fdat worked once I made the cases match.

I have a similar problem with a month select list, but I believe this is
caused by having values like "01" being retrieved and the select list
containing "1".

Gerald Richter wrote:
>
> > I have a routine that restores %fdat to the stored data values in the DB
> > so users can come back and edit a form, but I can't figure out how to
> > get select lists restored.
> >
> > I tried the following:
> >
> > <OPTION VALUE="[+ $abr=$STATE_ABBREVIATIONS[$row]+]"[.$ if( (defined
> > $fdat{'state'})
> > && ($fdat{'state'} eq $abr) )$] SELECT[$ endif $]>
> >
> > but this doesn't reset "state" to the value that was retrieved from the
> > database.
>
> Must be "SELECTED" and not SELECT, but it should be enought to simply set
> %fdat to the same values as it was before and Embperl will automaticly
> insert the SELECETED attribut to your OPTION tags.
>
> 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