我正在尝试从所有行获取数据并将其保存到数据库。如何从表中获取数据。 感谢您的帮助。
这是我的javascript文件
$(document).ready(function(){
$("input").click(function(){
$(this).next().show();
$(this).next().hide();
});
});
function add_row(){
var order_table = document.getElementById('order_list');
var food_name = document.getElementById('food0')
var food_quantity = document.getElementById('quantity')
// Insert new row
var new_row = order_table.insertRow(0);
var nee_cell0 = new_row.insertCell(0);
var nee_cell1 = new_row.insertCell(1);
var nee_cell2 = new_row.insertCell(2);
var nee_cell3 = new_row.insertCell(3);
var nee_cell4 = new_row.insertCell(4);
nee_cell0.innerHTML = "{{ forloop.counter }}";
nee_cell1.innerHTML = food_name.value;
nee_cell2.innerHTML = food_quantity.value;
nee_cell3.innerHTML = 'safakat';
nee_cell4.innerHTML = 'safakat';
}
这是我的HTML文件。
<body>
<input list="food_item" name="food0" id="food0" placeholder="Search for food item"><br>
<input type="number" name="unit_price">
<input type="number" name="quantity" id="quantity" placeholder="Enter The Quantity"><br>
<button onclick="add_row()">ADD ROW</button>
<table align="center" name = 'table'>
<tr>
<th>Sl. No.</th>
<th>Item</th>
<th name='abc'>Quantity</th>
<th>Unit Price</th>
<th>Ammount</th>
</tr>
</table>
<table align="center" id="order_list">
</table>
<datalist id="food_item">
{% for i in food %}
<option value="{{i.name}}">
{% endfor %}
</datalist>
</body>
我正在尝试request.POST.getlist('table_name')。但我得到的是空名单