Checking for duplicate entries in select box
<p>The following function, will dynamically add a new option value into a selectbox. Great feature, but it does not account and check for duplicate entries before adding new options into the select box. How can the code be modified such that it will alert the user that a duplicate entry has been found and to abort adding the same option value:</p>

<pre><code>function addref() {

var value = document.getElementById('refdocs').value

    if (value != "") {

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

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

        option.text = value

        select.add(option,select.option)

        select.selectedIndex = select.options.length - 1;
    }//end of if

}//end of function
</code></pre>
