[RESOLVED]remove duplicates

Is there a way to remove duplicates that are being returned in an object array?

My items are coming back like this

developer

developer

developer

admin

admin

admin

qa

qa

and so on, I want to show the items once, so I see it like

developer

      — all developers listed here

admin

  – all admins listed here

qq

  — all qa listed here

I’m seeing the roles listed with each user, I only want to see the role once then all users 

Removing duplicate you have to do it from sql query,  if you need help please post the table structure with data

and for the combobox list please follow the below link

http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_optgroup

http://jsfiddle.net/sushilbharwani/Xp8YK/

I’m not using SQL, I’m connecting to a SharePoint List and using JQuery to show the data on my page.  I was hoping there was a way in JQuery to remove the duplicates and only show the role once.

I’m not using a combo box either, i’m showing the data in a table

What format of data your getting back from Jquery, JSON or XML?

You can do like the following

Find more here : http://stackoverflow.com/questions/9229645/remove-duplicates-from-javascript-array
Find Another JSFiddle example here : http://jsfiddle.net/Guffa/Askwb/

var names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"];
var uniqueNames = [];
$.each(names, function(i, el){
    if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
});

Look this: http://stackoverflow.com/questions/9229645/remove-duplicates-from-javascript-array –>
Is the same the post before…sorry

Leave a Reply