Submitting a form from elm code

走远了吗. 提交于 2019-12-24 05:29:06

问题


I have this frameset division:

<frameset cols="*,200">
<frame name="main" src="/main.html">
<frame name="sidebar" src="/sidebar">
</frameset>

And this is my elm logic is inside main.html:

import Html exposing (..)
import Html.Attributes exposing (..)
view : Model -> Html Msg
view model =
      Html.form [method "POST", action "/sidebar", target "sidebar" ]
  [ input [ type_ "text" ,placeholder "user"] [],
  input [ type_ "password", placeholder "password"] [],
  input [ type_ "submit" ,value "Submit"] []
  ]

I want to invoke the form submission from my code.

How can I trigger the submission of the form from elm ?

EDIT:

This is what I came up with, pretty ugly:

submit2frame frm = attribute "onclick" ("javascript:this.form.target=" ++ frm ++ ";this.form.action=\"/" ++ frm ++ "\";this.form.submit();")

来源:https://stackoverflow.com/questions/46522003/submitting-a-form-from-elm-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!