What immediately springs to mind:

personSelect : List Person -> String -> Html MsgpersonSelect
personList selectedId =
    div []
        [ select [] (List.map (personOption selectedId) personList) ]
personOption : String -> Person -> Html MsgpersonOption selectedId person =
    ... use selctedId here now ...
    option [ value (toString person.id) ] [ text person.name ]

​

2016-08-23 7:04 GMT+02:00 Gabe Krambs <[email protected]>:

> Let's say I have a select element to choose a person, and I want to have a
> certain person, say with id = 3, to be initially selected. How do I pass
> this id down into my options, and then set the selected attribute to True
> in that options?
>
>
> Some sample code:
>
>
> personSelect : List Person -> String -> Html Msg
> personSelect : personList selectedId =
>     div []
>         [ select [] (List.map personOption personList) ]
>
>
> personOption : Person -> Html Msg
> personOption : person =
>     option [ value (toString person.id) ] [ text person.name ]
>
>
> Specifically, how do I get "selectedId" passed to "personOption"? Can I
> even do this using List.map?
>
>
> Thanks very much!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to