Detailed description of the parameter passing method between layui pop-up window and Parent and Child Window, layui pop-up window
This article describes how to pass parameters between layui pop-up window and parent and child windows. The details are as follows:
1. Open the child page on the parent page and pass parameters to the Child page
Function setChooseValues (ret) {var oView = document. getElementById ("userName"); var oValue = document. getElementById ("userIds"); var I = 0; if (ret! = Null) {oValue. value = ""; oView. value = ""; oView. title = ""; for (x in ret) {I ++; oView. title = oView. title + ret [x]. name + ","; oValue. value = oValue. value + ret [x]. id + ","; oView. value = oView. value + ret [x]. name + "\ n";} if (I = 0) {oView. value = "" ;}}} function OpenFrame (oValue, oView) {var dialogArgumentsA = new Array (oValue. value, spitToString (oView); var url = "$ {rootPath}/page/system/roleallot/role_all Ot. jsp "; layer. open ({type: 2, skin: 'layui-layer-Lan', title: 'selector ', fix: false, shadeClose: false, maxmin: true, id: 'selectuser', move: false, closeBtn: 2, // The following Code adds a button to open the window/* btn: ['OK', 'cancel'], btnAlign: 'C', yes: function (index, layero) {/* // layer. closeAll (); // close all pop-up layers // var parentWin = layero. find ('iframe') [0]; var parentWin = layer. getChildFrame ('body', index); alert (parentWin); parentWin. con TentWindow. doOk (); // layer. close (index); // click confirm to close this pop-up layer}, */area: ['750px ', '0000p'], content: url, success: function (layero, index) {var body = layer. getChildFrame ('body', index); var iframeWin = window [layero. find ('iframe') [0] ['name']; // obtain the window object on the iframe page. The method for executing the iframe page is: iframeWin. method (); var ids = dialogArgumentsA [0]. split (","); var names = dialogArgumentsA [1]. split (","); for (var I = 0; I <id S. length; I ++) {if (''! = Ids [I]) {var option = $ ("<option> "). val (ids [I]). text (names [I]); body. find ('select '). append (option );}}}});}
2. The child page transmits parameters to the parent page and closes the pop-up window.
Function newBuildReturnValue (selectName) {var ret = new Array (); $ ("#" + selectName + "option "). each (function () {// traverse all options var value = $ (this ). val (); // obtain the option value var text = $ (this ). text (); if (text! = '') {Var o = new Element (value, text, 0); ret. push (o) ;}}); return ret ;}// Click OK to pass the parameter to the subpage and close the window function doOk () {var ret = newBuildReturnValue ("select "); parent. setChooseValues (ret); var index = parent. layer. getFrameIndex (window. name); parent. layer. close (index) ;}// click Cancel to close the window function doCancel () {var index = parent. layer. getFrameIndex (window. name); parent. layer. close (index );}
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.