You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by James Ponder <ja...@db.com> on 2002/06/13 20:12:07 UTC

select/option looping

Hi,

Firstly, thanks for your help about headers/footers earlier, that was a great help - but I found out about EmbperlObject and now I'm using that, which is very nice indeed.  Embperl is really growing on me and I thank you for all the work you must have put in.

I have a new question - what is the Embperl way of doing:

@xyz = ('one', 'two', 'three');
$default = 'The default option';

                    <select name="sel" size="1">
                      <option value="default">[+ $default +]</option>
                      <option value="[+ $xyz[$row] +]">[+ $xyz[$row] +]</option>
                    </select>

i.e. to have a default?  The use of $row here causes my default to be replicated many times, and I get:

default
one
default
two
default
three

I don't want to prepend the default to my array because I want a different string to the value.  I could do:

                    <select name="sel" size="1">
                      <option value="[+ $xyz[$row] +]">[+ $xyz[$row] eq 'default' ? 'The default option' : $xyz[$row] +]</option>
                    </select>

But after you have a few extra cases like this it becomes messy, for example if I have several default and serveral data sources I am putting into this select.

It seems to me it would be nice if an <option> with a $row in it does not duplicate all of the contents of the <select> but only the contents of the enclosing <option>?


Best wishes, James
--
James Ponder



--

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.



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


Re: select/option looping

Posted by Gerald Richter <ri...@ecos.de>.
Hi,
>
> I have a new question - what is the Embperl way of doing:
>
> @xyz = ('one', 'two', 'three');
> $default = 'The default option';
>
>                     <select name="sel" size="1">
>                       <option value="default">[+ $default +]</option>
>                       <option value="[+ $xyz[$row] +]">[+ $xyz[$row]
+]</option>
>                     </select>
>

                     <select name="sel" size="1">
                       [$if $row == 0 $]<option value="default">[+ $default
+]</option>[$endif$]
                       <option value="[+ $xyz[$row] +]">[+ $xyz[$row]
+]</option>
                     </select>

>
> It seems to me it would be nice if an <option> with a $row in it does not
duplicate all of the contents of the <select> but only the contents of the
enclosing <option>?
>

Yes, we have discussed this recently, and it really seems a good idea to
change this. It works the way it works for historical reasons, but since for
2.0 you have to changes a few things anyways when you upgrade from 1.3, this
would be a good time to change the behaviour and I guess the feature that
two options (or in case of tables rows/columns) should be repeated is very
seldom.

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 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



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