Modify code to check for duplicate entries in select box
<p>I have the below, it dynamically adds a new value option into a selectbox. The problem i have is that it does not check for duplicate entries before adding new options into the select box.
Is there a way i can make a change to my code so it will alert the user that a duplicate entry is found and to stop adding the same option value?</p>

<pre><code>function refadd() {

var val = document.getElementById('docsref').value

    if (val != "") {

        var select = document.getElementById('docsref_list');

        var option = document.createElement('option');

        option.text = value

        select.add(option,select.option)

        select.selectedIndex = select.options.length - 1;
    }

}
</code></pre>
