[MKDoc-dev] Events Component, pull down menus
Chris Croome
chris at webarchitects.co.uk
Wed Oct 20 11:12:43 BST 2004
Hi
On Tue 19-Oct-2004 at 12:43:42PM -0400, Sam Tregar wrote:
> On Tue, 19 Oct 2004, Chris Croome wrote:
>
> > Due to a bug with select lists in an old version of IE for Macs
> > we have generally used a petal condition to find the <option>
> > that should be the default (in this case the current month) and
> > then added the selected="selected" attribute to this element and
> > then follow this with a a loop through the other options.
>
> I'm not sure I follow. What bug are you refering to?
A bug where by a select list like this:
<select>
<option>one</option>
<option optioned="optioned">two</option>
<option>three</option>
</select>
Doesn't display with option two selected but option one (as far as I
can remember the mac this was on has since died).
> Can you show me an example of the right way to do this?
To solve the above problem we have been putting the option that is
selected by default at the top, eg:
<select>
<option selected="selected">two</option>
<option>one</option>
<option>three</option>
</select>
Of course not having two between one and three is odd so I *think*
we have sometimes just repeted the selected element on the list.
> I spent an unfortunate amount of time getting the select lists to
> work as they are due to my mistaken impression that browsers would
> do the right thing with selected="0". It seems that although
> XHTML requires selected to have a value it doesn't matter what
> that value is!
It's supposed to have a value of "selected" if it is used, although
the spec isn't perhaps as clear about this as it could be:
http://www.w3.org/TR/xhtml1/#h-4.5
http://www.w3.org/TR/xhtml1/#C_10
> I also didn't realize that Petal would omit attributes set with
> undef, which seems to be an undocumented but very useful feature.
Ah, I'm not sure if this has been used much...
> Also, if I put the month names in the template how would you suggest I
> loop through them? I suppose I could resport to something like:
>
> <option value="01" title="01" i18n:translate="jan" petal:attributes="selected month/0/is_selected">January</option>
> <option value="01" title="01" i18n:translate="jan" petal:attributes="selected month/1/is_selected">January</option>
> If I understand correctly this will index $month->[0]->{is_selected},
> $month->[1]->{is_selected}, etc.
This is how the template for the properties of a document does the
language select list:
<select>
<option
selected="selected"
petal:if="self/selected_lang"
petal:attributes="value self/selected_lang/value;
title self/selected_lang/value;"
petal:content="self/selected_lang/label"
>English</option>
<option
petal:repeat="lang self/unselected_langs"
petal:attributes="value lang/value;
title lang/value;"
petal:content="lang/label"
>Klingon</option>
</select>
Which seems to be more-or-less how you suggested doing it?
Chris
--
Chris Croome <chris at webarchitects.co.uk>
web design http://www.webarchitects.co.uk/
web content management http://mkdoc.com/
More information about the MKDoc-dev
mailing list