简体   繁体   English

如何将弹出模式的值传递给原始表

[英]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.

相关问题 如何在成功提交表单时创建弹出模式? - How do I create a pop up modal on successful form submission? 如何在单击时连续获取值并将其传递给 QR 码生成器并弹出图像? [等候接听] - how do i get the values in a row on click and pass it to a QR Code generator and pop up the image? [on hold] 在fullCalendar上选择一个时隙后,如何弹出模态窗口? - How do I get the modal window to pop up when I select a time slot on fullCalendar? 如何在Twitter Bootstrap的弹出模式中引用html表单字段? - How do I reference an html form field inside Twitter Bootstrap's pop-up modal? 如何使用Meteor中的信息窗口按钮触发模式/弹出窗口? - How do I trigger a modal/pop up using an infowindow button in Meteor? 为什么模态弹出按下空格键? 我该如何预防? - Why does modal pop up pressing space bar press? How do I prevent it? 如何在单独的弹出窗口中打开div(而不是灯箱模式窗口) - How do I open a div in a separate pop up window (as opposed to a lightbox modal window) 如何创建模态弹出框 - Google Chrome 扩展程序 - How do I create a modal pop up box - Google Chrome Extension 仅在进行表单验证后,如何才能弹出模态? - How do I get my modal to pop up only after validation in form occurs? 如何在不重新启动页面的情况下将值传递给模态? - How do I pass values to modal without restarting the page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM