Guest User

Untitled

a guest
Feb 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import Html exposing (..)
  2. import Html.Attributes exposing (..)
  3. import Html.Events exposing (on, targetValue)
  4. import Json.Decode
  5.  
  6.  
  7. main =
  8. beginnerProgram { model = "", view = view, update = update }
  9.  
  10.  
  11. view model =
  12. div []
  13. [ select [ on "change" valueDecoder ]
  14. [ option [value "strawberry" ] [ text "strawberry" ]
  15. , option [value "chocolate" ] [ text "chocolate" ]
  16. , option [value "vanilla" ] [ text "vanilla" ]
  17. ]
  18. , div [] [ text (model) ]
  19. ]
  20.  
  21.  
  22. update msg model =
  23. toString msg
  24.  
  25. flavorToUpcase value =
  26. value
  27. |> String.toUpper
  28. |> Json.Decode.succeed
  29.  
  30. valueDecoder =
  31. Html.Events.targetValue
  32. |> Json.Decode.andThen flavorToUpcase
Add Comment
Please, Sign In to add comment