Solved

I need your help!  Loop thru dropdown multi select list

Posted on 2014-03-04
8
480 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now