Solved

I need your help!  Loop thru dropdown multi select list

Posted on 2014-03-04
8
478 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
Comment Utility
Thanks, Scott
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 58

Expert Comment

by:Gary
Comment Utility
$('#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
Comment Utility
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
Comment Utility
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
Comment Utility
More than Excellent!!!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now