Javascript 使用从modal添加的信息更新单元格表
我正在尝试使用从模式添加的信息更新我的单元格表。它需要通过将从model输入的名称放入网格来更新表,我将如何进行此操作 这是我的情态:Javascript 使用从modal添加的信息更新单元格表,javascript,html,bootstrap-modal,Javascript,Html,Bootstrap Modal,我正在尝试使用从模式添加的信息更新我的单元格表。它需要通过将从model输入的名称放入网格来更新表,我将如何进行此操作 这是我的情态: <div class="modal fade" id="myModal"> <div class="modal-dialog"> <div class="modal-content"> <div
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1>Reservation</h1>
</div>
<div class="modal-body">
<input type="text" name="field1" placeholder="Name" id="name">
<input type="text" name="field2" placeholder="Email" id="email">
<input type="text" name="field3" placeholder="PhoneNumber" id="phonenumber">
</div>
<div class="modal-footer">
<input class="btn submit" value="Submit">
<input class="btn btn-default" data-dismiss="modal" value="Close">
</div>
</div>
</div>
</div>
预订
这是javascript,我必须包含一个eventListener,当用户单击网格时触发它
<script>
var cells = document.querySelectorAll('td');
cells.forEach((e)=>{
e.addEventListener("click", ()=>{
$('.modal').modal("show");
})
})
var cells=document.querySelectorAll('td');
单元格。forEach((e)=>{
e、 addEventListener(“单击”,()=>{
$('.modal').modal(“show”);
})
})
我宣布该表如下:
<div class="container">
<div class="row">
<table>
<tr>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
</tr>
</table>
</div>
表单元格
表单元格
表单元格
表单元格
表单元格
表单元格
表单元格
表单元格
id
表格单元格
onchange
事件处理程序
getElementById
特定用例的代码笔:到目前为止,您尝试过什么吗?您是在使用数据库或其他东西来存储数据,还是只是在尝试使用JavaScript或类似的东西?我如何更改它?因此,当我从模式中输入名称时,当我单击“提交”时,它将更新更改。我不确定如何使您的答案符合我的问题。@JustinFulkerson您只需将相同的JS逻辑从输入字段的
onchange
事件处理程序放入不同类型的事件处理程序,例如提交按钮的onclick
处理程序或表单的onsubmit
处理程序-使用另一个id
从输入字段获取值@JustinFulkerson你能为这个创建一个新的代码吗?我会为你做的。这是代码笔,我有html的所有内容@贾斯汀·富尔克森,没关系。给我几分钟。