Solved

I need your help!  Loop thru dropdown multi select list

Posted on 2014-03-04
8
481 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
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)

861 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