表格提交无效?

时间:2014-06-08 22:46:20

标签: javascript html flask

我有这个简单的形式..我从用户那里获取输入,如下所示

<form action="/data" autocomplete="on" method="POST">
  <input id="search" name="search" type="text" placeholder="Search for song or artists..">
<input id="search_submit" value="Submit" type="submit">
 </form>

一切都很好......

现在..我想为它添加滑块并将滑块值发送到python。 我该怎么做?

我将表单修改为:

<form action="/data" autocomplete="on" method="POST">
  <input id="search" name="search" type="text" placeholder="Search for song or artists..">
    <input type="range" min="-1" max="1" value="0" step="0.05" onchange="showValue(this.value)" /><input id="search_submit" value="Submit" type="submit">
    <span id="range" style="color:#BDBDBD">0</span>
 </form>

但是我没有工作

Bad Request

The browser (or proxy) sent a request that this server could not understand.

修改

@app.route("/data", methods=['POST'])
def entry_post():
    query = request.form["search"]
    print request.form["range"] # I just added this line in the code

1 个答案:

答案 0 :(得分:1)

您缺少范围输入字段中的“name”属性。