title: Counting number of inputs filled
body: <p>I have 4 inputs on a form and I want to do a calculation based on the number of inputs filled.
  I have come up with this and it works in IE but not in FF. FF doesnt seem to like the multiple document.getElementById. Any help would be appreciated.</p>
  
  <pre><code>&lt;script type="text/javascript" language="javascript"&gt;
  function countlines(what) {
  var headline = 1 ;
  var oneline = 1 ;
  var twoline = 1 ;
  var webline = 1 ;
  
  var valhead = document.getElementById('adverttexthead').value;
  if (/^\s*$/g.test(valhead) || valhead.indexOf('\n') != -1)
  {var headline = 0};
  
  var valone = document.getElementById('adverttextone').value;
  if (/^\s*$/g.test(valone) || valone.indexOf('\n') != -1)
  {var oneline = 0};
  
  var valtwo = document.getElementById('adverttexttwo').value;
  if (/^\s*$/g.test(valtwo) || valtwo.indexOf('\n') != -1)
  {var twoline = 0};
  
  var valweb = document.getElementById('adverttextweb').value;
  if (/^\s*$/g.test(valweb) || valweb.indexOf('\n') != -1)
  {var webline = 0};
  
  (document.getElementById('webcost').value = "$" + ((headline + oneline + twoline + webline) * 16.50).toFixed(2));
  (document.getElementById('totallines').value = headline + oneline + twoline + webline);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;input name="adverttexthead" size="46" TYPE="text" onblur="countlines(this)" onkeypress="countlines(this)"&gt; 
  &lt;br&gt;
  &lt;input name="adverttextone" size="46" TYPE="text" onblur="countlines(this)" onkeypress="countlines(this)"&gt; 
  &lt;br&gt;
  &lt;input name="adverttexttwo" size="46" TYPE="text" onblur="countlines(this)" onkeypress="countlines(this)"&gt;
  &lt;br&gt;
  &lt;input name="adverttextweb" size="46" TYPE="text" onblur="countlines(this)" onkeypress="countlines(this)"&gt;
  
  
  &lt;input name="totallines" id="totallines" size="4" readonly="readonly" type="text"&gt;
  &lt;input name="webcost" id="webcost" size="6" readonly="readonly" type="text"&gt;
  </code></pre>