如何在用户输入数量时动态计算总价 [英] how to calculate total price dynamically when user enters quantity

查看:85
本文介绍了如何在用户输入数量时动态计算总价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在添加到购物车按钮上单击我在标签上显示弹出窗口,显示该产品的价格,在文本框中用户输入数量。输入数量后总价格应计算并显示在标签上..

On Add to cart button click i m showing popup on that on label showing price for that product and in textbox user enters quantity. after entering quantity total price should be calculate and display on label..

推荐答案

使用文本框的文本更改事件
use text change event of text box


你可以借助onblur()函数。下面我给出了一个例子。



You can take the help of onblur() function. Below i have given a example.

<script type="text/javascript">
    function f1()
    {
     document.getElementById('<%= Label1.ClientID %>').innerHTML = document.getElementById("Text1").value * 1000;
    }
    </script>







< input id =Text1type =text onblur =f1()/>




<input id="Text1" type="text" onblur="f1()" />


这篇关于如何在用户输入数量时动态计算总价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆