title: Javascript for survey
body: <p><strong>Background</strong>
  I'm working on a survey in javascript which contains ten "yes" or "no" questions. I'd like to code the "yes" responses to = 1 and the "no" responses to = 0. I'm using the  html tag so they can only choose one or the other.</p>
  
  <p>Then I'd like to have the sum of their responses added up and divided by the total number of questions to yield a percentage. Depending on their percentage, I would then like to output some HTML text to a field below it with some helpful tips and advice relevant to their score.</p>
  
  <p>To be clear, though I'm learning javascript now, I don't expect anyone to code the thing for me, but I'd just like to know where I should be looking for answers to make this happen. I'm thinking I need to use the if/else conditions to account for the yes/no responses and then maybe I need another function() to do the rest of the calculations.</p>
  
  <p>I've tried a number of different variations of if/else statements but I'm just confused about how to 1) code the yes/no responses; 2) integrate them into if/else statements.</p>
  
  <p>I'll add an abbreviated snippet of code with two sample questions that I'm trying to get working now.</p>
  
  <pre><code>function calc (form) {
  var score1;
  var score2;
  var Result = form.Result.value;
  
  
  if (form.Question1.options[form.Question1.selectedIndex].value =    "Yes") { score1 = 1;
   } else {
   score1 = 0;
   }
  
  if (form.Question2.options[form.Question2.selectedIndex].value = "Yes") {  score2 = 1;
   } else {
   score2 = 0;
   }
  
  Result = (((score1 + score2) / 10) * 100);
  
  if (Result == 80) {
   document.getElementById("recommendation").innerHTML = "&lt;h4&gt;Heading here&lt;/h4&gt; &lt;p&gt;Advice goes here based on their result&lt;/p&gt;"
     }  
   }
  </code></pre>