During the development, I encountered such a problem. Customers can fill in their delivery address and create new ones, but at the same time, they can also choose the ones that were filled in before. Since our customers are merchants themselves and there are many addresses, it is obviously inappropriate to simply list their previous addresses in a drop-down box. Moreover, the customer requires that the address be filtered by name. In this way, if you select the address, you must open a small window to complete it. So, how can the values filled in the small window be passed back?
js has a method that showsModalDialog is used more often in this case. Its function is to open a modal window. What is the modal window? It means that the parent window cannot be operated after opening. Only when the child window is operated and closed can the parent window continue to operate. Going back to the initial question, it is to select an entry for an address and click to trigger the event btn_click().
Parent window JS
function btn_click() { var returnValue = window.showModalDialog('chooseAddr.aspx', window, 'dialogWidth=500px;dialogHeight=600px;status=no'); if (vReturnValue !== "" && vReturnValue !== undefined) { // Process the return value of the child window} }In the child window, after the user completes a series of actions such as filtering selection, the event returnVal() is triggered when the user confirms.
function returnVal() { var rtArr = new Array(); rtArr[0] = "test0"; rtArr[1] = "test1"; window.returnValue = retArr; window.close();//Close the child window to continue the operation of the parent window}In this way, the "data interaction" of the parent-child window is completed. By the way, how does the parent-child window pass the value to the child window? In this example, we need to know the id of the operator to select the address we filled in before.
The first parameter of window.showModalDialog is to add the parameter?id=xxx to the open child window address. Yes, it is OK to pass it in the get method.
The above JS acquisition data implementation method is all the content shared by the editor. I hope it can give you a reference and I hope you can support Wulin.com more.