title: JavaScript - Check for unique values in select boxes
body: <p>Couldn't find anything quite what I was looking for but if I've missed something obvious I'm sorry.  I'm basically trying to have a JavaScript function check that each of a number of select boxes have unique values before the form is submitted to then be entered into a database.</p>
  
  <p>There could be any number of select boxes but all follow a similar naming format in the form of:</p>
  
  <pre><code>operator_address_type_0
  operator_address_type_1
  operator_address_type_2
  etc.
  </code></pre>
  
  <p>I was just wondering how a JavaScript function could be set up to loop through all of the select boxes and alert the user and stop the submitting if any are found to have the same value.</p>
  
  <p>Thanks for any help.</p>
  
  <p>EDIT:</p>
  
  <p>Here is some simplified HTML of my current select boxes.  I've had to simplify it a lot as the table that they are in is all loaded via AJAX from querying a database.</p>
  
  <pre><code>&lt;select name="operator_address_type_0"&gt;
  &lt;option value="Main"&gt;Main&lt;/option&gt;
  &lt;option value="Payment"&gt;Payment&lt;/option&gt;
  &lt;option value="Poster"&gt;Poster&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;select name="operator_address_type_1"&gt;
  &lt;option value="Main"&gt;Main&lt;/option&gt;
  &lt;option value="Payment"&gt;Payment&lt;/option&gt;
  &lt;option value="Poster"&gt;Poster&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>It is like that but there could be more options in the future, I just want to check that there is only one main address, one payment address, one poster address etc.</p>