Multiple Select Dropdown List with JavaScript - Get key

Place for comments, problems, questions, or any issue related to the JavaScript / PHP scripts from this site.
dmgatwork
Posts: 4

Multiple Select Dropdown List with JavaScript - Get key

Question on the Double Select Dropdown List example/code from: https://coursesweb.net/javascript/multip ... vascript_t

I have this example working for my application, and have learned a couple of things. I can't figure out how to store for display the key in the SList.scontent and where to add that line of code.

In the example below, I want to put in a variable for display later on the key word ajax:

Select WebSite: MarPlo.net Select Category: ajax
http://www.marplo.net/ajax/

my understanding is not at that level yet.
Thanks

Admin
Hi
The "option" parameter in the getSelect() method contains the selected option /value, which is the key in the SList objects.
If you want to store that value (key) in a variable for using it later, you can make like in this example:

Code: Select all

var some_var ='';  //Your Variable

var SList = new Object();

//the rest of code for SList object...

SList.getSelect = function(slist, option){
  some_var = option;  //store current selected option /key

//the rest of code of this method...
}
- Define your variable before the SList object, and assing to it the the value of the option parameter in the getSelect() method.

dmgatwork
This worked just fine, got the info out of the object I needed. Still getting up to speed on objects. Thanks again.

Similar Topics