- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我输入印度卢比格式的数字并且结果也以印度卢比格式粘贴到总计输入框时,如何才能实现?请帮忙解决这个问题。
<input onblur="findTotal()" type="text" name="qty" id="qty1"/><br>
<input onblur="findTotal()" type="text" name="qty" id="qty2"/><br>
<input onblur="findTotal()" type="text" name="qty" id="qty3"/><br>
<input onblur="findTotal()" type="text" name="qty" id="qty4"/><br>
<input onblur="findTotal()" type="text" name="qty" id="qty5"/><br>
<input onblur="findTotal()" type="text" name="qty" id="qty6"/><br>
<input onblur="findTotal()" type="text" name="qty" id="qty7"/><br>
<input onblur="findTotal()" type="text" name="qty" id="qty8"/><br>
<br><br>
Total : <input type="text" name="total" id="total"/>
这里是 JavaScript
<script type="text/javascript">
function findTotal(){
var arr = document.getElementsByName('qty');
var tot=0;
for(var i=0;i<arr.length;i++){
if(parseInt(arr[i].value))
tot += parseInt(arr[i].value);
}
document.getElementById('total').value = tot;
}
</script>
最佳答案
您可以使用 Intl.NumberFormat
方法来为您处理这一切,我已经创建了下面的演示。
它与您现有的代码类似,只是它首先通过数字格式化程序传递值。
var formatter = new Intl.NumberFormat('en-IN', {
style: 'currency',
currency: 'INR',
minimumFractionDigits: 2,
});
//formatter.format(2500); /* $2,500.00 */
function findTotal(){
var arr = document.getElementsByName('qty');
var tot = 0;
for(var i=0;i<arr.length;i++){
if(parseInt(arr[i].value))
tot += parseInt(arr[i].value);
}
document.getElementById('total').value = formatter.format(tot);
}
<input onkeyup="findTotal()" type="text" name="qty" id="qty1"/><br>
<input onkeyup="findTotal()" type="text" name="qty" id="qty2"/><br>
<input onkeyup="findTotal()" type="text" name="qty" id="qty3"/><br>
<input onkeyup="findTotal()" type="text" name="qty" id="qty4"/><br>
<input onkeyup="findTotal()" type="text" name="qty" id="qty5"/><br>
<input onkeyup="findTotal()" type="text" name="qty" id="qty6"/><br>
<input onkeyup="findTotal()" type="text" name="qty" id="qty7"/><br>
<input onkeyup="findTotal()" type="text" name="qty" id="qty8"/><br>
Total : <input type="text" name="total" id="total"/>
有关浏览器支持,请参阅: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat#Browser_compatibility
关于javascript - 如何在网页中将数字转换为印度卢比格式,例如 10,000.00,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54196398/
我知道西欧 Windows 的默认编码是 ISO-8859-1,网络标准的默认编码是 UTF8,但我希望(谷歌让我失望)有人知道 Windows/Visual Studio/C# 的默认编码印度的软件
我正在尝试使用 twitter4j 的流媒体方法从印度地区捕获推文。我正在使用低于纬度和经度的值,但我得到的结果低于异常值。 纬度/经度无效:8.07、68.12、37.10、97.42 这是我的代码
导入请求 x = requests.get(' https://www1.nseindia.com/live_market/dynaContent/live_watch/equities_stock_
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 8年前关闭。 Improve this que
我正在评估 iText 作为 Java swing 应用程序的 PDFGenerator。输出应该是“马拉地语”,这是一种与印地语类似但不相同的印度本地语言。 出于评估目的,这是我尝试打印的文本: म
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 11 年前。 Improve thi
是否有任何工具/网站可以让我以多种印度语言(卡纳达语、马拉地语、泰米尔语、印地语等)中的一种输入一些文本并将其翻译成英语。 谷歌翻译目前只支持印度语言中的印地语。 最佳答案 我意识到这是一个很老的问题
我无法找到在 android-google-billing-pop-up 中显示介绍价格的方法, 我的问题: as you can see that introductory price are no
我是一名优秀的程序员,十分优秀!