我有一张表格,里面有一张表格。但是,当我点击提交按钮时,POST数据并不包含任何输入数据...任何想法为什么?
<table class="table table-hover" name="share_table">
<thead>
<tr>
<th>●</th>
<th>Name</th>
<th>Email</th>
<th>Allocation</th>
<th></th>
</tr>
</thead>
<form id="myform" action="" method="post">
<tbody>
<tr>
<th scope="row">●</th>
<td><input type="text" id="name" placeholder="eg. John Smith" class="form-control"></td>
<td><input type="email" id="email" placeholder="eg. john@email.com" class="form-control"></td>
<td><input type="text" id="allocation" placeholder="1000" class="form-control"></td>
<td></td>
</tr>
</tbody>
</table>
<div class="text-right">
<p>
<input type="submit" value="Create Project" class="cta"/>
</form>
</p>
</div>
<button class="cta" name="add">Add</button>
我使用jquery这样添加和删除行 - 不是很漂亮,但是当涉及到js时,我是一个新手。
<script>
var inx = 1;
</script>
<script>
function removex(ref){
$(ref).remove();
};
</script>
<script>
jQuery(document).ready(function() {
$('button[name="add"]').on('click', function(){
var table = $('table[name="share_table"]');
inx = inx + 1;
var trx = '<tr id="row' + inx.toString() + '" />';
var tr = $(trx);
var td = $('<td />');
var idrow = $('<th scope="row"/>').html('●');
var input = $('<input placeholder="1000" />').attr({'class' : 'form-control'});
var inputz = $('<input placeholder="eg. john@email.com"/>').attr({'class' : 'form-control'});
var inputx = $('<input placeholder="eg. John Smith" />').attr({'class' : 'form-control'});
var bx = '<a href="#" onclick="removex(row' + inx.toString() ;
var bxx = bx + ')"> x</a>';
var button = $(bxx);
var namex = 'name' + inx.toString();
var emailx = 'email' + inx.toString();
var allocationx = 'allocation' + inx.toString();
var tdName = td.clone().append(inputx.attr({'type': 'text', 'id': namex}));
var tdEmail = td.clone().append(inputz.attr({'type': 'email', 'id': emailx}));
var tdAllocation = td.clone().append(input.attr({'type': 'text', 'id': allocationx}));
var tdRow = td.clone().append(idrow);
var tdAction = td.clone().html(button);
tr.append(tdRow);
tr.append(tdName);
tr.append(tdEmail);
tr.append(tdAllocation);
tr.append(tdAction);
table.append(tr);
});
});
</script>
答案 0 :(得分:1)
我认为这是因为您没有在表单标记中的操作中放置页面链接