如何将javascript数组值传递给python flas

2024-09-28 21:50:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个html表单,它在提交后生成值数组,我想把这些值数组传递给python flask。在

我试着在fieldid=“Result”中使用隐藏表单。但烧瓶没有识别id,它只从名称字段中获取值。在

我不知道该怎么办,我对烧瓶框架还不熟悉。在

这是我的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>

我想处理这个文档.getElementById(“Result”).innerHTML=e;到烧瓶。我试了很多方法,但都没有成功。在

请帮帮我。在

谢谢。在


Tags: 表单烧瓶valuevarfunctioncustomer数组result
1条回答
网友
1楼 · 发布于 2024-09-28 21:50:40

我试过了这个。它在将值设置为hidden type id之后,将名称属性赋予hidden场。这个会帮助你的

<input type="hidden" name="hidden" id="Result">
document.getElementById("Result").value = e;

这将把数组值设置为隐藏类型id

^{pr2}$

相关问题 更多 >