【问题标题】:How do i process multiple if statements in a sinatra post method如何在 sinatra post 方法中处理多个 if 语句
【发布时间】:2012-10-04 09:37:02
【问题描述】:

我正在尝试根据我的复选框的值做多项事情。我在 htlm 表单上有这个:

<input id="one" checkbox" type="checkbox" value="1">

<input id="two" checkbox" type="checkbox" value="2">

在辛纳特拉 post '/process-data' 做 一=参数[:一] 二 = 参数[:二]

   if one = "1"
    "One"
   end
   if two = "2"
    "Two"
   end

结束

我无法从第二个 if 语句中获取结果,我的问题是,我如何让 Sinatra 能够从第二个 if 中获取值。

【问题讨论】:

    标签: sinatra checkbox


    【解决方案1】:

    尝试:

    "One" if one == "1"
    "Two" if two == "2"
    

    您使用的是=,而不是=====

    【讨论】:

      猜你喜欢
      • 2015-08-21
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-20
      • 2022-01-11
      • 1970-01-01
      • 2013-08-16
      相关资源
      最近更新 更多