How can I check if Dynamically created Select Boxes have been selected
<p>I have some code that has one contact select box hard coded and then if you click on a add button it adds more contacts. Each contact can be selected from a dropdown and give a location in at location text box. </p>

<p>I want on submit to be able to know if they have selected someone and if not I want to clear out the Location box as there cannot be a location if there is no contact.</p>

<pre><code>&lt;!--- The myContactCount variable is set in another part of javascript this is the current count plus one of the number of current select boxes. ---&gt;

   &lt;script type="text/javascript" language="javascript"&gt;
      var e='';
      var contactSelectedValue='';

      for(var i=1;1&lt;myContactCount;i++){
         e = document.getElementById('myContactID_'+i);
         contactSelectedValue = e.options[e.selectedIndex].value;
         /* I am trying to alert the value so I can then use a if statement to check for null or even change the 'Select a Contact' value to 0 and test for that. */

        alert(contactSelectedValue);
     }
   &lt;/script&gt;

   &lt;!--- the ID will be 1-100 depending on how many contacts they have added ---&gt;

   &lt;select name="myContactID_#ID#"&gt;
      &lt;option value=""&gt;Select a Contact&lt;/option&gt;
      &lt;option value="1"&gt;Abe&lt;/option&gt;
      &lt;option value="2"&gt;Barbara&lt;/option&gt;
      &lt;option value="3"&gt;Cavlin&lt;/option&gt;
   &lt;/select&gt;
</code></pre>

<hr>

<p>So after they are created dynamically they code would look like this. </p>

<pre><code>&lt;select name="myContactID_1"&gt;
   &lt;option value=""&gt;Select a Contact&lt;/option&gt;
   &lt;option value="1"&gt;Abe&lt;/option&gt;
   &lt;option value="2"&gt;Barbara&lt;/option&gt;
   &lt;option value="3" selected="selected"&gt;Cavlin&lt;/option&gt;
&lt;/select&gt;

&lt;select name="myContactID_2"&gt;
   &lt;option value=""&gt;Select a Contact&lt;/option&gt;
   &lt;option value="1"&gt;Abe&lt;/option&gt;
   &lt;option value="2" selected="selected"&gt;Barbara&lt;/option&gt;
   &lt;option value="3"&gt;Cavlin&lt;/option&gt;
&lt;/select&gt;


&lt;select name="myContactID_3"&gt;
   &lt;option value=""&gt;Select a Contact&lt;/option&gt;
   &lt;option value="1" selected="selected"&gt;Abe&lt;/option&gt;
   &lt;option value="2"&gt;Barbara&lt;/option&gt;
   &lt;option value="3"&gt;Cavlin&lt;/option&gt;
&lt;/select&gt;
</code></pre>
