JQuery not returning select box values if no element is selected -
Not sure what is happening here, I should remember something. I have two selected boxes and users can choose those elements to which they want to download data elements, hold the screen here:
Everything is very good when the user moves some elements back to the" Data Concepts "box, which has no selected elements in the" selected data " Does not leave, as seen here:
Here is the code that is gaining the values of" selected data "box:
var ExportSel = []; $ ('# DataList2') Each (function () {ExportSel = $ ('# DataList2'). Val ();}); But it gives empty array if nothing is selected, regardless of the number of elements in the "empty data" box. However, when I see it in firebug, it shows that elements and value selectors are present in the box.
Am I understanding the .each function, the wrong function or something even more fundamental?
A great thanks in advance, always impressed by the Stack community!
a & lt; Multiple and select elements of the element are all selected options but you do not care that the options given in the selected data column are selected, you want an array of them all. So you need to repeat the options, get their value. var ExportSel = []; $ ("# DataList2 Options") Each (function () {ExportSel.push (this.value);});
Comments
Post a Comment