Double Click in Selection Box to bring up popup

Posted on 2004-10-26
Last Modified: 2012-05-05
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:

I would like to create it in a way that people can double-click on the name of the employee in the Selected Employee box and that double-clicking on that name will bring up a popup with that employee's profile. I am guess something like this but just do not know how to write it in JScript:

{"profile.asp?EMP_ID=" + document.formname.SelectedEmployee,SelectedItem.value);

<SELECT NAME="SelectedEmployee" OnDoubleClick="javascript:PopUpProfile()">

Is this possible and if so, how?
Question by:pgkooijman
    LVL 63

    Accepted Solution

    Like this:

    function PopUpProfile(theSel){"profile.asp?EMP_ID=" + theSel.value, "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>


    Author Comment

    Hi ZVonko, I am afraid everything works but it is not getting any value for EMP_ID. theSel.value is undefined. Any way to fix that problem?
    LVL 3

    Expert Comment

    try this:"profile.asp?EMP_ID=" + theSel.options[thieSel.selectedIndex].value, "profile", "top=100,left=100,height=400,width=300");

    normally when using the multiple attribute in select-elements you have to use a loop to check which options are selected. but you are using a doubleclick so when you first click a option it becomes selected the second time the ondblclick-event is fired.
    LVL 63

    Expert Comment

    Moin' Alex :-)

    @pgkooijman: are you talking about my upper example or about yout version?
    Any code can have typos, also mine ;-)


    Author Comment

    Whoopsie, my error. It works, thanks, points given!
    LVL 63

    Expert Comment

    No problem.
    Thanks for points.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: From Zero to Hero with Nodejs & MongoDB

    Interested in Node.js, but don't know where to start or how to learn it properly? Confused about how the MEAN stack pieces of MongoDB, Expressjs, Angularjs, and Nodejs fit together? Or how it's even possible to run JavaScript outside of the browser?

    This article shows how to read a single webpage's HTML into a string variable, and it also shows how to automate a sequence so you can read and process a list of webpages.  I was tasked with reading and parsing a series of webpages to collect some s…
    Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
    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…

    909 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

    13 Experts available now in Live!

    Get 1:1 Help Now