?
Solved

I need your help!  Loop thru dropdown multi select list

Posted on 2014-03-04
8
Medium Priority
?
486 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…
Suggested Courses

801 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