开发者

Submitting a hash directly with HTML <form> tag

I need to submit a hash of attributes directly from the form tag. Is this possible?

<form action="/members/1/comments" method="post">
  [some element] {"coordinator\_id"=>"1", "time"=>"1230", "info_link"=>"cnn.com"}
  <submit>Post</submit>
</form>

This hash should arrive as 'comment' => {"coordinator_id"=>开发者_StackOverflow中文版"1", "time"=>"1230", "info_link"=>"cnn.com"}


Almost possible, but not recommended, you should give your values proper names instead, but here is what you asked for:

<form action="/members/1/comments" method="post">
  <input name="comment[coordinator_id]" type="hidden" value="1" />
  <input name="comment[time]" type="hidden" value="1230" />
  <input name="comment[info_link]" type="hidden" value="cnn.com" />
  <submit>Post</submit>
</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜