Popup window to Fill Selection Box in parent window

Posted on 2004-10-26
Last Modified: 2008-02-01
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.
Question by:pgkooijman
    LVL 63

    Accepted Solution

    What about this:

    function PopUpProfile(theSel){
      nw ="select.htm", "profile", "top=100,left=100,height=400,width=300");
    <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>

    And here the popup page "select.htm":

    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;
    <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>
    LVL 63

    Expert Comment

    Does upper option pass back work for you?
    It worked in my tests.


    Author Comment

    Just finished implemented it, it works! Thanks and again points given :)
    LVL 63

    Expert Comment

    Thank you too.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved." Ralph Waldo Emerson Introduction: One of the wonderful things about the web is that it makes it s…
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now