1
有没有可能在Yesod中用“onclick”设置调用Haskell函数?在Yesod中调用Haskell函数onclick
我要调用的函数:
save_all :: WidgetT App IO[()] save_all = mapM save_cur_answers (exam_questions exam_1)
save_cur_answers :: Question -> WidgetT App IO()
save_cur_answers quest = do
q_box1 <- runInputPost $ ireq checkBoxField (answer_id ((answer_list quest) !! 0))
q_box2 <- runInputPost $ ireq checkBoxField (answer_id ((answer_list quest) !! 1))
q_box3 <- runInputPost $ ireq checkBoxField (answer_id ((answer_list quest) !! 2))
q_box4 <- runInputPost $ ireq checkBoxField (answer_id ((answer_list quest) !! 3))
setSession (question_id quest) $ bool_to_cookie [q_box1, q_box2, q_box3, q_box4]
在
<input type="radio" onclick="save_all" name="tabs" id="tab#{question_id quest}">
我想所有的复选框的结果,并将其保存在cookie每次我点击单选按钮。 save_cur_answers
使用唯一的answer_id查找复选框,返回值为Bool
,并存储所有4个值。