remove duplicate from my list

Hello,

I have a list that I need to remove any duplicate.

SelectedSeg = "5,5,5,5,5,4"

SelectedIndustry = "8690,8690,8690,6320,6320,8630"

SelectedCompany = "279780,275056,116591,108106,108559,278806"

my select instead should be like this:

SelectedSeg = "5,4"

SelectedIndustry ="8690,6320,8630"

SelectedCompany = "279780,275056,116591,108106,108559,278806"
 
Please, see my code:


function setGroupOptions()
	{
		var	SelectedSeg=""	
		var	SelectedIndustry=""	
		var	SelectedCompany=""	
		var dropdownGroup = $("#DispGroupList");
		var GetSelectedCompany = $("#DispCompanyList option:selected");

		$('#DispCompanyList option:selected').each(function() {
    		vals = $(this).val()
    		vals=vals.split(",")
    		SelectedSeg+= "," + vals[0]
			SelectedIndustry += "," + vals[1]
			SelectedCompany += "," + vals[2]
   		})
			SelectedSeg = SelectedSeg.substring(1)
			SelectedIndustry = SelectedIndustry.substring(1)
			SelectedCompany = SelectedCompany.substring(1)
			
		$.get( "filterGroup.cfm?filter=1&SelectedSeg=" + SelectedSeg + "&SelectedIndustry=" + SelectedIndustry + "&SelectedCompany=" + SelectedCompany, function (data) {
			dropdownGroup.html( data );
		});
	}

Open in new window

lulu50Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
This seems to work, notice I'm switching to arrays

		var	SelectedSeg=new Array();
		var	SelectedIndustry=new Array();
		var	SelectedCompany=new Array();

		$('#DispCompanyList option:selected').each(function() {
    			vals = $(this).val()
    			vals=vals.split(",")
           
    			SelectedSeg.push(vals[0])
			SelectedIndustry.push(vals[1])
			SelectedCompany.push(vals[2])
   		})
        SelectedSeg = SelectedSeg.filter(function(el, position) {
            return SelectedSeg.indexOf(el) == position;
        })
        SelectedIndustry = SelectedIndustry.filter(function(el, position) {
            return SelectedIndustry.indexOf(el) == position;
        })
        SelectedCompany = SelectedCompany.filter(function(el, position) {
            return SelectedCompany.indexOf(el) == position;
        })

Open in new window

0
lulu50Author Commented:
Hi Cathal,

I have an error

it says "Object doesn't support this property or method"

Object doesn't support this property or method
0
GaryCommented:
What version of jquery are you using
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

lulu50Author Commented:
jquery-1.10.2.min.js
0
lulu50Author Commented:
jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8.  Since IE 6/7/8 are still relatively common, we recommend using the 1.x version unless you are certain no IE 6/7/8 users are visiting the site.

My users uses IE 7/8 so, newer version will not work for me.

I have right now this version: jquery-1.10.2.min.js
0
GaryCommented:
What browser are you using?
Try the attached test page.
ee-remove.php
0
GaryCommented:
Just looked at the screenshot again!
Have you tried running the page in a real browser. Shouldn't be running in quirks mode or IE8 compat mode - this is the likely reason.
0
lulu50Author Commented:
My users are using IE 8 so I have to develop this tool in IE8

I am running the project in real browser. but I have the error above showing.

doesn't support this property or method.
0
GaryCommented:
But disable IE8 compatibility mode. Running IE8 in quirks mode is like running the browser as IE5
What type of DOCTYPE are you using?
0
lulu50Author Commented:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
0
GaryCommented:
Use
<!DOCTYPE html>

And see if you still get the same error

(Of course come 30 days time they shouldn't even be using the internet with those old (to be) unsupported browsers and you should be looking at enforcing an upgrade to use the site.)
0
GaryCommented:
Ok scrap that, just checked and .filter is not included til IE9

Be back shortly.
0
lulu50Author Commented:
the same error

it gives me this error When the browser tries to read these lines.

  SelectedSeg =  SelectedSeg.filter(function(el, position) {
            return SelectedSeg.indexOf(el) == position;[embed=file 838521]
        })
        SelectedIndustry = SelectedIndustry.filter(function(el, position) {
            return SelectedIndustry.indexOf(el) == position;
        })
        SelectedCompany = SelectedCompany.filter(function(el, position) {
            return SelectedCompany.indexOf(el) == position;
        })

Open in new window

error.png
0
GaryCommented:
Well this was easier than expected in jQuery - Go jQuery!

		var SelectedSeg=new Array();
		var SelectedIndustry=new Array();
		var SelectedCompany=new Array();

		$('#DispCompanyList option:selected').each(function() {
    			vals = $(this).val()
    			vals=vals.split(",")
           
    			SelectedSeg.push(vals[0])
			SelectedIndustry.push(vals[1])
			SelectedCompany.push(vals[2])
   		})
        SelectedSeg = $.unique( SelectedSeg );
        SelectedIndustry = $.unique( SelectedIndustry );
        SelectedCompany = $.unique( SelectedCompany );

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lulu50Author Commented:
Wow that's is just beautiful!!!!!

it is GREAT!!!!!!!!

Thank you for all your help.  

I still have one last step on this than I'm good.

I'll post a new post soon.

Thank you again and again and again.

This is great!!!!
0
lulu50Author Commented:
Excellent ++ lol
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.