我在使用代号CanyonS 价格计算器, 并有一些Javascript的麻烦。
第一个字段根据信贷小时数计算学费数额。
第二个领域(我遇到麻烦的地方)应该是从第一个领域选择的信贷小时数,除以3以获得班级数,然后乘以100以达到教科书所需的金额。
我尝试过与 Javascript 和一些 ASP 达成这个等式, 但一直没有成功。 我不是 Javascript 专家, 但这里是当前版本的代码。 任何帮助都非常感激!!
< 强 > HTML 标记 强 >
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, <%=budgetRS("budget_BooksandSupplies_sem1")%>), which is set to "100".
<fieldset>
<p>1 class = 3 credit hours.</p>
<p>
<label>Number of Credit Hours: <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="<%=FormatNumber(budgetRS("budget_Tuition_sem1"), 2)%>"/></label>
<span class="staticPrice">
</span>
</p>
<p>
Textbook Estimate ($<%=budgetRS("budget_BooksandSupplies_sem1")%>/3 credit hours):
<input type="hidden" name="f_7-textbooks" value="{f_4}/3*<%=budgetRS("budget_BooksandSupplies_sem1")%>" />
</p>
</fieldset>
< 强力 > 标注 强 >
<script type="text/javascript">
$(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 ($<%=budgetRS("budget_Tuition_sem1")%>/credit hour) ;
items[ f_7-textbooks ] = Textbook Estimate ($<%=budgetRS("budget_BooksAndSupplies_sem1")%>/credit hour) ;
});
});
</script>
该计算器的完整代码可在以下网址查阅:http://media.briercrest.ca/calculators/collegecalculator.asp 。