title: Price Calculator Javascript help - sharing a variable's value
body: <p>I am using CodeCanyon's Price Calculator, and am having some Javascript trouble.</p>
  
  <p>The first field calculates the tuition amount based on the number of credit hours.</p>
  
  <p>The second field (where I'm having trouble) is supposed to take the number of credit hours selected from the first field, divide it by 3 to get the number of classes, and then multiply by 100 to arrive at the amount of money needed for textbooks.</p>
  
  <p>I have tried achieving this equation with Javascript and some ASP, but haven't been successful. I'm no Javascript expert, but here is the code as it presently stands. Any help is much appreciated!</p>
  
  <p><strong>HTML markup</strong></p>
  
  <p>The "f_4" and "f_7-textbooks" are variables named in the script below.
  f_4 is the number of credit hours selected.
  In f_7-textbook, I've attempted to call the value of f_4, divide it by 3 and multiply it by the value sent from the database (hence, &lt;%=budgetRS("budget_BooksandSupplies_sem1")%>), which is set to "100".</p>
  
  <pre><code>&lt;fieldset&gt;
  &lt;p&gt;1 class = 3 credit hours.&lt;/p&gt;
  &lt;p&gt;
      &lt;label&gt;Number of Credit Hours: &lt;input class="spinner" type="text" id="f_4" name="f_4" data-spinner='{"min": 0, "max": 42, "step": 3}' data-default="0" value="3" data-cost="&lt;%=FormatNumber(budgetRS("budget_Tuition_sem1"), 2)%&gt;"/&gt;&lt;/label&gt; 
      &lt;span class="staticPrice"&gt;
      &lt;/span&gt;
  &lt;/p&gt;
  &lt;p&gt;
      Textbook Estimate ($&lt;%=budgetRS("budget_BooksandSupplies_sem1")%&gt;/3 credit hours): 
      &lt;input type="hidden" name="f_7-textbooks" value="{f_4}/3*&lt;%=budgetRS("budget_BooksandSupplies_sem1")%&gt;" /&gt;
  &lt;/p&gt;
  &lt;/fieldset&gt;
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function(){
      var form = $('#jquery-order-form');
  
      //form.find('span.staticPrice').remove();
      form.find('option').each(function(i){
          var opt = $(this)
          opt.text(opt.val());
      });
  
      var items = [];
      items['f_4'] = 'Credit Hours ($&lt;%=budgetRS("budget_Tuition_sem1")%&gt;/credit hour)';
      items['f_7-textbooks'] = 'Textbook Estimate ($&lt;%=budgetRS("budget_BooksAndSupplies_sem1")%&gt;/credit hour)';
  
      });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>The full code for this calculator is available at  <a href="http://media.briercrest.ca/calculators/collegecalculator.asp" rel="nofollow">http://media.briercrest.ca/calculators/collegecalculator.asp</a></p>