English 中文(简体)
价格计算计算器 Javascrap 帮助 - 共享变量 s 值
原标题:Price Calculator Javascript help - sharing a variable s value

我在使用代号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

最佳回答

您正在尝试在服务器端代码中使用客户端值, 该代码无法访问此数据, 并导致输出 。

<input type="hidden" name="f_7-textbooks" value="{f_4}/3*100">

您应该只使用客户端侧值在客户端侧码中,反之亦然。

下面的代码应该能得到你需要的值 。

$( .ui-spinner-button ).click(function() { $(this).siblings( input ).change(); });

$( #f_4 ).spinner().change(function() {
   var f4Val = $( #f_4 ).val();
   var calcValue = (f4Val/3)*100;
   $( input[name="f_7-textbooks"] ).val(calcValue);
});

"http://jsfiddle.net/Nicholas_Murray/Dc43A/1/" rel="no follow" >iddle

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签