title: Make field required based on dropdown
body: <p>I'm hoping for some help getting around an issue I just can't seem to solve.</p>
  
  <p>I need to make a field required based on a value of "new" in a select box.  I have googled, and looked at some questions here, but can't seem to get it to work in my case.</p>
  
  <p>Here's my current code, which doesn't quite seem to work - I keep getting undefined for dd, and for the builder fields.</p>
  
  <pre><code>function selection() {
      alert("got in");
      var x;
      var number_of_input = $("#formtable select").length;
      alert(number_of_input);
      for (var i = 1; i &lt; number_of_input; i++) {
          if (i &gt; 1) { x = (i * 9) + 5; }
          else { x = 14 };
          alert(x);
          var name = "vnew_or_resold" + x;
          var sel = document.getElementById(name);
          var opt = sel.options[sel.selectedIndex];
          var dd = opt.text;
          alert(dd);
          var builder = "vbuilder_name" + (x + 1);
          alert(builder);
          var build = builder.val();
          alert(build);
  
          if (dd == "new") {
              if (build == "") {
                  alert('Mandatory');
                  return false;
              }
          }
      }
      return true;
  }
  </code></pre>
  
  <p>I have include the "alerts" because I need to see the values that are being inputted.</p>
  
  <p>Also, the values of x in the for loop work...there are six static fields then 9 static in a table, and 9 in an unlimited number of dynamic rows.  The x is reading the correct rows - that I know for sure.  My problem really starts with the section starting at</p>
  
  <pre><code>var sel = document.getElementById(name);
  </code></pre>
  
  <p>Additionally, it's not actually going through all the dynamic rows, probably because either true or false are being registered - but I'm not sure.</p>
  
  <p>I appreciate any help in advance.</p>