Quantcast
Viewing all articles
Browse latest Browse all 6517

New Post: $().SPServices GetListItems Distinct Values

I'm about 4 years late to this party, but I was having the exact same issue earlier today and quickly found a very simple jQuery solution (credit to StackOverflow). It (appears) to loop through all of your drop-down's options and removes any duplicate text values.

JS:
$(document).ready(function() {

var usedNames = {};
$("select[name='divSel'] > option").each(function () {
    if(usedNames[this.text]) {
        $(this).remove();
    } else {
        usedNames[this.text] = this.value;
    }
});
});

HTML:
<select id="divSel" name="divSel" style="width:475px;" onchange="selectDate();" />


Hopefully this helps anyone else looking for the same functionality!

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>