You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Florian 'cit' Adamsky <ci...@spin.de> on 2005/12/20 14:13:47 UTC

option selected problem

Hiho,
        
i've a little wired problem with a pice of code.
        
<select name="firma">
    <option> ------ </option>
    [$ foreach $firma (@firmenid) $]
        [$ if $fdat{firma} eq $firma $]
            <option selected>[+ $firma +]</option>
        [$ else $]
            <option>[+ $firma +]</option>
        [$ endif $]
    [$ endforeach $]
</select>
        
If $fdat{firma} equal with $firma, then it writes only <option> without
the "selected" option. If i write "<option selecte>", this appears. I
hope you can help me.
        
My Setup:
        
* libembperl-perl 2.0rc2-1 (cgi-mode)
* apache2-common 2.0.54-5
        
greets
cit


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: option selected problem

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

>         
> i've a little wired problem with a pice of code.
>         
> <select name="firma">
>     <option> ------ </option>
>     [$ foreach $firma (@firmenid) $]
>         [$ if $fdat{firma} eq $firma $]
>             <option selected>[+ $firma +]</option>
>         [$ else $]
>             <option>[+ $firma +]</option>
>         [$ endif $]
>     [$ endforeach $]
> </select>
>         

You should rewrite as

 <select name="firma">
     <option> ------ </option>
     [$ foreach $firma (@firmenid) $]
           <option value="[+ $firma +]">[+ $firma +]</option>
     [$ endforeach $]
 </select>

If you have the value attribute, Embperl will take care about selecting the
correct option

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org