[Petal] option selected

Chris Croome chris at webarchitects.co.uk
Sun Dec 19 00:51:00 GMT 2004


Hi

On Sat 18-Dec-2004 at 09:07:54PM -0000, Simon McCaughey wrote:
> I can't seem to get a reasonable solution to the option selected
> problem

Yeah, this is confusing at first, basically you need to have two
option elements, something like this:

  <select 
    title="Select a language for the document."
  >
    <option
      selected="selected"
      petal:attributes="value self/selected_lang/value"
      petal:content="self/selected_lang/label"
    >English</option>
    <option
      value="i-klingon"
      petal:repeat="lang self/unselected_langs;"
      petal:attributes="value lang/value"
      petal:content="lang/label"
    >Klingon</option>
  </select>
  
Here the first <option> element is used for the selected item and
then there is a loop through the unselected ones.

I have never worked out how to do it any other way, but doing it
this way is good for when the unprocessed templates are opened in a
web browser, just like the table row example from a few days ago. 

I *think* there was a MKDoc site for Petal at one stage, but now
http://petal.mkdoc.com/ doesn't seem to exist -- perhaps we should
set up a site and use it for example like this? Or we could create a
/petal/ section on mkdoc.org for this...

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 Petal mailing list