title: determining if a field exists on a form
body: <p>I have a form field (a series of checkboxes) that's being created dynamically from a database, so it's possible that the field will not exist on the form (if there are no matching values in the database). I have some code that needs to execute based on whether the field exists, and pull in the values that are selected if it does exist. I can't seem to get javascript to acknowledge that this field exists, though. Here's what I've tried:</p>
  
  <pre><code>function displayAction(){
      var f = document.adminForm;
      var a = f.action;
  
      if(f.prefix.value!="-") {
          a = a + '&amp;task=callExclusionDisplay&amp;prefix=' + f.prefix.value;
      }
      else {
          var exclusions = document.getElementById("exclusions");
          if (exclusions != null){
              alert("exclusions set");
              a = a + '&amp;task=callExclusionCreate&amp;prefix=' + f.prefix.value + '&amp;exclusions=' + exclusions.join();
          }
      }
      alert('after if, action is ' + a);
  }
  </code></pre>
  
  <p>The code never passes the if statement checking to see if exclusions is not null, even though when I look at the page there are a number of checkboxes named exclusions (with the id also set to exclusions). Is the issue with !=null because it's a group of checkboxes, rather than a single form element? How can I get this to work? If I skip the test for null, the code throws errors about exclusions not being defined if the database doesn't return any matching values.</p>