P
Peter Kirk
Hi,
I want to open a popup-window which displays a list to the user. From this
list, the user can select an item, and the data regarding this item is then
transferred to some fields on the main window (and the popup then closes).
But I am having several problems. I have an example "main.html" which opens
an example "lookup.html". In the actual application "lookup.html" is
generated dynamically be a server, and will have different lists depending
on a "typeid" sent to the server in the request. In the example below I want
the possibility to select from 2 lists: one called FUNCTION, and one called
MATERIAL.
But I can't even get the "function" data to be transferred to the main
window. What is the problem?
Also, what is the easiest way to tell "lookup.html" what fields to write to
on the main window? The field names will be different depending on the
particular list shown (I guess I will need to get the server which generates
the lists to also ensure that the javascript on "lookup.html" matches the
correct field names etc).
Thanks,
Peter
The MAIN window (main.html):
<html>
<head>
<title>
Test Popup
</title>
</head>
<script language="javascript">
function newWindow(url,window,param)
{
popupWindow=open(url, window, param);
if (popupWindow.opener == null) popupWindow.opener = self;
}
</script>
<body>
<table width="100%" border="1" bgcolor="f1f8ff">
<form method="post">
<tr>
<td valign="top" width="20%">
<b>FUNCTION</b>
</td>
<td valign="top" width="40%">
<input type="button" value="pop"
onclick="newWindow('lookup.html?typeid=5000','catalogue','width=500,height=4
00')" />
<input type="hidden" value="2" name="function" />
<input type="text" value="f2" name="function_shortcut"
style="width:25px" />
<input type="text" value="function 2" name="function_name" />
</td>
</tr>
<tr>
<td valign="top" width="20%">
<b>MATERIAL</b>
</td>
<td valign="top" width="40%">
<input type="button" value="pop"
onclick="newWindow('lookup.html?typeid=5001','catalogue','width=500,height=4
00')" />
<input type="hidden" value="11" name="material" />
<input type="text" value="m1" name="material_shortcut"
style="width:25px" />
<input type="text" value="material 1" name="material_name" />
</td>
</tr>
</form>
</table>
</body>
</html>
An example POPUP window (lookup.html):
<html>
<head>
<title>
Lookup
</title>
</head>
<script language="javascript">
function choose( id, shortcut, name )
{
window.opener.document.forms[0].function.value = id;
window.opener.document.forms[0].function_shortcut.value = shortcut;
window.opener.document.forms[0].function_name.value = name;
window.close();
}
</script>
<body>
<table width="100%" border="1" bgcolor="f1f8ff">
<tr>
<td valign="top" width="20%">
<b>Lookup List</b>
</td>
<td>
<table width="100%">
<tr>
<td>
<a href="#" onclick="choose(1,'f1','function 1')">func 1</a>
</td>
</tr>
<tr>
<td>
<a href="#" onclick="choose(2,'f2','function 2')">func 2</a>
</td>
</tr>
<tr>
<td>
<a href="#" onclick="choose(3,'f3','function 3')">func 3</a>
</td>
</tr>
<tr>
<td>
<a href="#" onclick="choose(4,'f4','function 4')">func 4</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
I want to open a popup-window which displays a list to the user. From this
list, the user can select an item, and the data regarding this item is then
transferred to some fields on the main window (and the popup then closes).
But I am having several problems. I have an example "main.html" which opens
an example "lookup.html". In the actual application "lookup.html" is
generated dynamically be a server, and will have different lists depending
on a "typeid" sent to the server in the request. In the example below I want
the possibility to select from 2 lists: one called FUNCTION, and one called
MATERIAL.
But I can't even get the "function" data to be transferred to the main
window. What is the problem?
Also, what is the easiest way to tell "lookup.html" what fields to write to
on the main window? The field names will be different depending on the
particular list shown (I guess I will need to get the server which generates
the lists to also ensure that the javascript on "lookup.html" matches the
correct field names etc).
Thanks,
Peter
The MAIN window (main.html):
<html>
<head>
<title>
Test Popup
</title>
</head>
<script language="javascript">
function newWindow(url,window,param)
{
popupWindow=open(url, window, param);
if (popupWindow.opener == null) popupWindow.opener = self;
}
</script>
<body>
<table width="100%" border="1" bgcolor="f1f8ff">
<form method="post">
<tr>
<td valign="top" width="20%">
<b>FUNCTION</b>
</td>
<td valign="top" width="40%">
<input type="button" value="pop"
onclick="newWindow('lookup.html?typeid=5000','catalogue','width=500,height=4
00')" />
<input type="hidden" value="2" name="function" />
<input type="text" value="f2" name="function_shortcut"
style="width:25px" />
<input type="text" value="function 2" name="function_name" />
</td>
</tr>
<tr>
<td valign="top" width="20%">
<b>MATERIAL</b>
</td>
<td valign="top" width="40%">
<input type="button" value="pop"
onclick="newWindow('lookup.html?typeid=5001','catalogue','width=500,height=4
00')" />
<input type="hidden" value="11" name="material" />
<input type="text" value="m1" name="material_shortcut"
style="width:25px" />
<input type="text" value="material 1" name="material_name" />
</td>
</tr>
</form>
</table>
</body>
</html>
An example POPUP window (lookup.html):
<html>
<head>
<title>
Lookup
</title>
</head>
<script language="javascript">
function choose( id, shortcut, name )
{
window.opener.document.forms[0].function.value = id;
window.opener.document.forms[0].function_shortcut.value = shortcut;
window.opener.document.forms[0].function_name.value = name;
window.close();
}
</script>
<body>
<table width="100%" border="1" bgcolor="f1f8ff">
<tr>
<td valign="top" width="20%">
<b>Lookup List</b>
</td>
<td>
<table width="100%">
<tr>
<td>
<a href="#" onclick="choose(1,'f1','function 1')">func 1</a>
</td>
</tr>
<tr>
<td>
<a href="#" onclick="choose(2,'f2','function 2')">func 2</a>
</td>
</tr>
<tr>
<td>
<a href="#" onclick="choose(3,'f3','function 3')">func 3</a>
</td>
</tr>
<tr>
<td>
<a href="#" onclick="choose(4,'f4','function 4')">func 4</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>