[英]How do I pass the values of the pop up modal to the original table
Original form原始表格
<table>
for($i=0;$i<5;$i++)
{
<tr>
<td><input name="data[$i]"/> <button onclick="getElementById('modal').style.display('block')">
</button></td>
</tr>
}
</table>
The pop up modal弹出模态
<div id="modal">
<table>
<tr>
<td>Value 1</td>
<td>Value 2</td>
</tr>
</table>
</div>
How do I get the td value from popup modal to the original form Table tr td upon click on that particular row?单击该特定行时,如何将 td 值从弹出式模式获取到原始表单 Table tr td?
First of all, you need to add an event
to the <td>
tags.首先,您需要向<td>
标签添加一个event
。
<td onclick="return sendValue(this);">Value 1</td>
In the calling (parent) window add such JS code:在调用(父)窗口中添加这样的 JS 代码:
function HandlePopupEvent(result) {
alert("the selected popup value: " + result);
}
In the child window(popup) code add this:在子窗口(弹出)代码中添加:
function sendValue(sender) {
try {
window.opener.HandlePopupResult(sender.innerHTML);
}
catch (err) {}
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.