There is a form on the first page, by clicking on the button on the page a window opens with a table, and when you double-click on a row from the table, the data should fall into the form fields.
If the form and the table are placed on the same page, then everything works, but if you put the table into another window, which is created by a function, it no longer works.
If I understand correctly, the problem with the globalization of functions, probably.
Here is the code:
Home Page:
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> <meta charset="utf-8"> </head> <body> <button type="button" onclick="NewWindow()">Банки</button> <br /><br /> Bank Name: <br /> <textarea id='bank' cols=56 rows=6></textarea> Bank Adress: <br /> <textarea id='bic' cols=56 rows=6></textarea> <script> var textarea_bank = document.getElementById('bank'), textarea_bic = document.getElementById('bic'); function comm(){ var tmp = new Array(); // два вспомогательных var tmp2 = new Array(); // массива get = new Array(); var url = location.search; // строка GET запроса if(url != '') { tmp = (url.substr(1)).split('&'); // разделяем переменные for(var i=0; i < tmp.length; i++) { tmp2 = tmp[i].split('='); // массив get будет содержать get[tmp2[0]] = tmp2[1]; // пары ключ(имя переменной)->значение } } } function NewWindow() { var textarea_bank = document.getElementById('bank').innerHTML, textarea_bic = document.getElementById('bic').innerHTML; myChildWin = window.open("test.html?bank="+textarea_bank+"&bic="+textarea_bic, "_blank", "toolbar=no, scrollbars=no, resizable=no, top=100, left=100, width=600, height=600"); } </script> </body> </html> Table window:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>test</title> </head> <body> <table id="mySuperTBL"> <tr> <td><b>BankName</b> </td> <td><b>BIC</b> </td> </tr> <tr id='1' ondblclick='comm(this)'> <td>Bank</td> <td>Adress</td> </tr> </table> </body> </html>