Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Html exposing (..)
- import Html.Attributes exposing (..)
- import Html.Events exposing (on, targetValue)
- import Json.Decode
- main =
- beginnerProgram { model = "", view = view, update = update }
- view model =
- div []
- [ select [ on "change" valueDecoder ]
- [ option [value "strawberry" ] [ text "strawberry" ]
- , option [value "chocolate" ] [ text "chocolate" ]
- , option [value "vanilla" ] [ text "vanilla" ]
- ]
- , div [] [ text (model) ]
- ]
- update msg model =
- toString msg
- flavorToUpcase value =
- value
- |> String.toUpper
- |> Json.Decode.succeed
- valueDecoder =
- Html.Events.targetValue
- |> Json.Decode.andThen flavorToUpcase
Add Comment
Please, Sign In to add comment