【发布时间】:2018-02-11 09:27:39
【问题描述】:
我有一个 html 表单,它在提交后生成值数组,我想将这些值数组传递给 python 烧瓶。
我尝试使用带有 id="Result" 字段的隐藏表单。但是烧瓶无法识别 id 它仅从名称字段中获取值。
我不知道该怎么做,我是 Flask 框架的新手。
这是我的 javascript 代码:
function add_element_to_array()
{
array[x] = ([
document.getElementById("user").value,
document.getElementById("customer").value,
document.getElementById("product").value,
document.getElementById("start").value,
document.getElementById("end").value,
document.getElementById("status").value,
document.getElementById("description").value
]);
alert("Element: " + array[x] + " Added at index " + x);
x++;
document.getElementById("user").value = "";
document.getElementById("customer").value = "";
document.getElementById("product").value = "";
document.getElementById("start").value = "";
document.getElementById("end").value = "";
document.getElementById("status").value = "";
document.getElementById("description").value = "";
}
function display_array()
{
var e = "<hr/>";
//var myJsonString;
for (var y=0; y<array.length; y++)
{
e += "Element " + y + " = " + array[y] + "<br/>";
//myJsonString = JSON.stringify(array[y]);
//console.log(myJsonString)
//return array[y];
}
document.getElementById("Result").innerHTML = e;
}
</script>
<form action="/flaskprocess" method="POST">
<input type="hidden" id="Result" value="" />
<input type="submit" value="Submit" />
</form>
我想将这个 document.getElementById("Result").innerHTML = e; 处理到烧瓶中。我尝试了很多方法,但没有得到。
请帮帮我。
谢谢。
【问题讨论】:
标签: javascript python arrays web flask