-3
我想写入插入函数,以便输入到文本框中的数据将转到新的表格行。在insertdata()
里面,数据应该发送到表格的新行。如何将数据添加到HTML表中
这里是我的代码:
<div class="banner-info" align="center">
<span><label>Customer Name </label></span>
<span><input type="text" class="text-center" required="" placeholder="Enter Customer Name"></span>
<span><label>Customer Address </label></span>
<span><input type="text" class="text-center" required=""></span>
<span><label>Customer telephone </label></span>
<span><input type="text" class="text-center" required=""></span>
</div>
<div class="logo">
<input type="button" onClick="insertData()">
</div>
<script language="javascript">
function insertData() {
var name=$('')
}
</script>
<table id="t1">
<caption>Customer Table</caption>
<colgroup>
<col span="2" class="c2">
<col>
<col class="c1">
</colgroup>
<thead>
<tr>
<th>
Customer Name
</th>
<th>
Customer Address
</th>
<th>
Customer Telephone
</th>
</tr>
</thead>
</table>
下''元素添加''
然后在您的函数创建元素'',创建元素''指定您希望得到答案的域。 – Nitheesh
回答
要插入表中的东西:
在你的情况,而不是 “我们在这里”,检索的内容输入字段,并添加到单元格内。
不要忘了在html中添加
tbody
到你的表中。编辑:
,使用PHP,如果存储你的数据,例如,在一个数组,你把所有的人一个数组,你只需要插入这样的:
来源
2017-01-30 11:50:39 Ollaw
我想从php做到这一点。我该怎么做? –
我已经编辑了php – Ollaw
试试这个。
来源
2017-01-30 11:52:54 Nitheesh
的答案感谢它很帮我.. –
不客气。添加CSS和javavsscript以清除添加后的字段也 – Nitheesh
@RaminduSamarawickrama如果这是所需的结果,请批准我的答案。 – Nitheesh
也许我想你可以通过JavaScript使用
tbody
元素(你缺少)的innerHTML
财产和追加到它,比如好,我有一个简单的建议,使事情更容易–使用输入字段的ID,以便采取值将更容易。像...
并为您的JavaScript函数,你可以使用这样的:
最终代码:
希望能帮助到你!!!
来源
2017-01-30 12:10:15 Sree
相关问题