[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Popup window to Fill Selection Box in parent window

This is related to my previous question about the 2 dynamic Selection Boxes:

I have 2 selection boxes: 1 with a list of employees and 1 with a list of selected employees. Using arrows you can move an empoyee from the Available List to the Selected List. This works great and makes it very clear for our clients. Now I would like to add the following functionality:

The Available Selection box lists employees depending on a certain query depending on the chosen Department. What I would like to add is a button called 'Add Custom Employee' that brings up a popup window where I can select an employee from any department and add it to the list of Selected Employees. Problem is how can I do that. The popup window will be easy to make and will bring up a list of employees depending on your search query. Now once the employee has been found that the user wants to add to the Selected Employee list he should be able to press a 'Add this Employee' button that will close the popup and post back two variables to the parent window: EMP_ID and EMP_NAME. These variables should then be placed in the parent window in the form of an added option in the Selected Employees box.

I hope the question is clear but I can imagine it is not so to summarize:

How can I post back 2 variables from a popup window to its parent window and place them as an option in a selection box on the parent window.
0
pgkooijman
Asked:
pgkooijman
  • 3
1 Solution
 
ZvonkoSystems architectCommented:
What about this:

<html>
<head>
<SCRIPT>
function PopUpProfile(theSel){
  nw = window.open("select.htm", "profile", "top=100,left=100,height=400,width=300");
  nw.focus();
}
</SCRIPT>
</head>
<body>
<form>
<SELECT NAME="SelectedEmployee" MULTIPLE onDblClick="PopUpProfile(this)">
<OPTION VALUE="EMP_ID1">Employee Name1</OPTION>
<OPTION VALUE="EMP_ID2">Employee Name2</OPTION>
<OPTION VALUE="EMP_ID3">Employee Name3</OPTION>
</SELECT>
</form>
</body>
</html>


And here the popup page "select.htm":

<html>
<head>
<script>
function putSel(EMP_ID, EMP_NAME){
  opt = opener.document.forms[0].SelectedEmployee.options;
  opt.length ++;
  opt[opt.length-1].value = EMP_ID;
  opt[opt.length-1].text = EMP_NAME;
  window.close();
}
</script>
</head>
<body>
<a href="javascript:putSel('EMP_IDa', 'EMP_NAMEa')">EMP_NAMEa</a><br>
<a href="javascript:putSel('EMP_IDb', 'EMP_NAMEb')">EMP_NAMEb</a><br>
<a href="javascript:putSel('EMP_IDc', 'EMP_NAMEc')">EMP_NAMEc</a><br>
</body>
</html>
0
 
ZvonkoSystems architectCommented:
Does upper option pass back work for you?
It worked in my tests.

0
 
pgkooijmanAuthor Commented:
Just finished implemented it, it works! Thanks and again points given :)
0
 
ZvonkoSystems architectCommented:
Thank you too.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now