javascript - 使用 Javascript 动态创建行,然后发送到 Flask。没有信息被传输
问题描述
我的问题是我动态创建的行(通过 javascript)没有被发送到我的后端 python 函数。
我创建了一个脚本,它创建一个包含 7 列的表行,每列是一个 html 输入。用户将使用这些输入来输入有关产品的信息。(序列号/零件号等...)
function Add_row() {
var tbl = document.getElementById('sct_components_table');
var iteration = tbl.tBodies[0].rows.length;
newRow = tbl.tBodies[0].insertRow(-1);
var newCell = newRow.insertCell(0);
newCell.classList.add("sct_components_input")
newCell.innerHTML = '0' + iteration;
var newCell1 = newRow.insertCell(1);
newCell1.classList.add("sct_components_input");
var el = document.createElement('input');
el.type = 'text';
el.name = 'quantity';
el.value = '';
newCell1.appendChild(el);
var newCell2 = newRow.insertCell(2);
newCell2.classList.add("sct_components_input");
var el2 = document.createElement('input');
el2.type = 'text';
el2.name = 'part_number';
newCell2.appendChild(el2);
var newCell3 = newRow.insertCell(3);
newCell3.classList.add("sct_components_input");
var el3 = document.createElement('input');
el3.type = 'text';
el3.name = 'serial_number';
newCell3.appendChild(el3);
var newCell4 = newRow.insertCell(4);
newCell4.classList.add("sct_components_input");
var el4 = document.createElement('textarea');
el4.type = 'text';
el4.name = 'description';
newCell4.appendChild(el4);
var newCell5 = newRow.insertCell(5);
newCell5.classList.add("sct_components_input");
var el5 = document.createElement('input');
el5.type = 'text';
el5.name = 'installed_by_cm';
newCell5.appendChild(el5);
var newCell6 = newRow.insertCell(6);
newCell6.classList.add("sct_components_input");
var el6 = document.createElement('input');
el6.type = 'text';
el6.name = 'installed_after_cm';
newCell6.appendChild(el6);
var newCell7 = newRow.insertCell(7);
newCell7.classList.add("sct_components_input");
var el7 = document.createElement('textarea');
el7.type = 'text';
el7.name = 'notes';
newCell7.appendChild(el7);
}
输入由具有以下代码的烧瓶框架收集
temp_multi_quantity = request.form.getlist('quantity')
temp_multi_part_number = request.form.getlist('part_number')
temp_multi_serial_number = request.form.getlist('serial_number')
temp_multi_description = request.form.getlist('description')
temp_multi_installed_by_cm = request.form.getlist('installed_by_cm')
temp_multi_installed_after_cm = request.form.getlist('installed_after_cm')
temp_multi_notes = request.form.getlist('notes')
如果我在 html 页面上手动创建表格行,它们将成功上传。只有“Javascript 行”被忽略。
此代码模仿在以下位置找到的示例:http ://www.mredkj.com/tutorials/tablebasics5.html 此示例很旧并且使用 php 而不是 python,所以这可能是我感到困惑的地方,但我在页面上使用了 wireshark它似乎正在提交。
如果有人能阐明我误解了什么概念/我犯了哪些错误,将不胜感激。
解决方案
推荐阅读
- .net - 如何修复“Oracle.EntityFrameworkCore 没有实现”类型中的“方法 'get_Info”。
- java - 工件部署期间出错:注销 MBean 时出现问题:javax.management.InstanceNotFoundException
- asp.net-core - 如何将模型传输到 Blazor 服务器端中的 Razor 组件?
- javascript - 使用 Forge 对二进制数据进行 SHA256 哈希
- vb.net - 使用 VB.Net 2 读取和写入文本文件中的特定行
- javascript - 使用 setItem 设置多个状态值和使用 useEffect 这样做有什么区别?
- powershell - 如何区分try catch语句中的Invoke-WebRequest异常(HTTP错误码)
- c# - 如何获取自定义属性的通用集合
- sqlite - sqlite 通过 JOIN 提高两个(或多个)表的查询速度
- c# - IIS自动将子文件夹制作成应用程序,为什么?