如何从弹出窗口中收集表单值

how to collect form values from a pop up window

本文关键字:表单 窗口      更新时间:2023-09-26

我希望用户单击主文档上的一个按钮,这将打开一个新的弹出窗口,其中包含一个表单。我希望用户将他们的数据输入到表单中,然后关闭窗口,以便能够从新窗口收集用户提供的数据。到目前为止,我可以生成弹出窗口,但无法从表单中收集用户提供的值

var OpenWindow = window.open("", "newwin", "height=250,width=250,toolbar=no,scrollbars=" + scroll + ",menubar=no");
                OpenWindow.document.write('<B><br>' + '<font color="blue" size = "4" >' +
                        "Please complete the following: " + '</B></font>');
                OpenWindow.document.write("<FORM>Image height(px)  <input type='text' name='image_height' id='image_height' value='800' size='5'></input><br>Image width(px)  <input type='text' name='image_width' id='image_width' value='800' size='5'></input><INPUT TYPE='BUTTON' VALUE='Submit' id='submit'  onClick='window.close()'></FORM>");
                var realWidth   = OpenWindow.document.getElementById('image_height').value;
                var realHeight  = OpenWindow.document.getElementById('image_width').value;

您可能希望使用overlay来解决此问题,因为这样可以更容易地执行您想要的操作(您的表单元素将可以像在同一页面中一样访问)。