Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I need your help!  Loop thru dropdown multi select list

Posted on 2014-03-04
8
Medium Priority
?
489 Views
Last Modified: 2014-03-05
Hi,

when the user select segment the Industry has to populate based on the segment.
the user should be allowed to select multiple segment.

<select name="DispSegmentList" class="SearchBySelect5" id="DispSegmentList" style="background-color: #f8fafc; width: 120px; height: 500px;" onchange="setIndustryOptions();" size="180" multiple="multiple">
<option value="4">
<option value="5">
<option value="1">
<option value="2">
</select>

<select name="DispIndustryList" class="SearchBySelect5" id="DispIndustryList" style="background-color: #f8fafc; width: 250px; height: 500px;" onchange="setCompanyOptions();" size="180" multiple="multiple">
<option value="4,8630" data-IndustryNumber="8630">
<option value="4,3710" data-IndustryNumber="3710">
<option value="4,5010" data-IndustryNumber="5010">
<option value="4,9990" data-IndustryNumber="9990">
<option value="4,8660" data-IndustryNumber="8660">
<option value="4,3310" data-IndustryNumber="3310">
</select>

function setIndustryOptions()
	{
			var dropdownIndustry = $("#DispIndustryList");
		var dropdownSegment = $("#DispSegmentList");
		var selectedSegment = $("#DispSegmentList option:selected");
	$.each(selectedSegment, function(index, value) {
	
		//here I want to separate the value.
SelectedSeg = ?
SelectedIndustry = ?
	});

	if (selectedSegment == '') {
		dropdownSegment.html('');
		dropdownIndustry.html('');
		return;
		}
		
		$.get( "filterIndustry.cfm?Segment=" + SelectedSeg + "Industry=" + SelectedIndustry, function (data) {
			dropdownIndustry .html( data );
		});
	}

Open in new window

0
Comment
Question by:lulu50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 

Author Comment

by:lulu50
ID: 39904201
Thanks, Scott
0
 
LVL 58

Expert Comment

by:Gary
ID: 39904219
Just loop thru the selected values

$('#DispSegmentList option:selected').each(function() {
//do whatever here for each selected value.
})

Maybe I am missing something?
0
 

Author Comment

by:lulu50
ID: 39904248
Cathal,

my options values are "4,8630"  the first digit is the segment and the second digit is the industry

I need to set those field like this.

SelectedSeg = '4,5'
SelectedIndustry = '8630,3710'

so I can do the filter in the filterIndustry.cfm
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 58

Expert Comment

by:Gary
ID: 39904293
$('#DispIndustryList option:selected').each(function() {
     SelectedSeg = $(this).val()
     SelectedIndustry = $(this).attr('data-IndustryNumber')
})

Open in new window

Normally I would use the data prop for the custom data attribute but it doesn't seem to work in this scenario

Hold off on this...
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39904334
SelectedSeg=""
SelectedIndustry=""
$('#DispIndustryList option:selected').each(function() {
    vals = $(this).val()
    vals=vals.split(",")
    SelectedSeg+= "," + vals[0]
    SelectedIndustry += "," + vals[1]
   })
SelectedSeg=SelectedSeg.substring(1)
SelectedIndustry =SelectedIndustry .substring(1)

Open in new window

0
 

Author Comment

by:lulu50
ID: 39906204
Cathal,

That is exactly what I want.  

Thank you so much for all your help.

Thank you!! Thank you!!! and Thank you!!!!
0
 

Author Closing Comment

by:lulu50
ID: 39906206
More than Excellent!!!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

618 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