title: How to calculate a value in Javascript in an Acrobat form? - how do I write the result?
body: <p>I'm totally new to Javascript as used in Acrobat forms. </p>
  
  <p>I simply want to count the number of non-empty fields and write the result into another field. I've tried putting the following under calculate > custom calculation script:</p>
  
  <pre><code>var sum = 0;
  for ( i = 0; i &lt; 10; i++ ) {
      f = "item" + i;
      if (getField( f ).valueAsString) {sum += 1;
      }
  }
  </code></pre>
  
  <p>Is this correct and how do I actually write sum ?</p>