根据选定的下拉值循环进行jquery计算 [英] jquery calculations as per selected dropdown value loop

查看:75
本文介绍了根据选定的下拉值循环进行jquery计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进行计算.用户选择下拉货币时.系统计算所选货币并将其从下拉列表转换为INR货币值.记录来自mysql db,记录数将从一条记录增加到300条记录.在此,用户需要从下拉菜单中更改每种货币,然后系统会将此所选货币值转换为INR值.这确实是一个忙碌的任务.因此,如果用户从下拉列表中更改一种货币值,则系统应将整个行货币值更改为选定的下拉值,并且系统应根据某些公式进行计算以将值更改为INR.所有这些都工作正常.

Iam trying to do a calculation. When a user selects a dropdown currency. The system calculates and converts the selected currency from the dropdown to INR currency values. The records are coming from mysql db and the record count will be from one record to 300 records. Here the user needs to change each currency from the drop down and the system converts this selected currency value to INR value. Its really a hectic task. So If the user changes one currency value from dropdown, the system should change the entire row currency value to the selected dropdown value and the system should calculate on certain formulae to change the value to INR. All these is working fine.

现在,iam面临的问题是对jquery实现公式.

Now the issue iam facing is to implement the formulae to the jquery.

这是我所做的小提琴:

如果您可以检查jquery部分中的小提琴,我已经使用了一个公式

If you can check the fiddle in the jquery part i have used a formula

 var newTotal = currency==="INR" ? totalINR : (totalINR * conversionRate / row.find('.inrvalue').val()).toFixed(3);

上述公式有误:

iam正在查看的实际公式是

The actual formula iam looking at is

if (currency==="INR")
        {
            var newTotal = totalINR; 
        } else if (currency==="USD")
        {
            var newTotal = (row.find('.total1.').val() *  row.find('.inrvalue').val());
        } else {
            var newTotal = ((row.find('.inrvalue').val() / conversionRate) * row.find('.total1.').val());
        }

如何将现有公式更改为此?当我实现此公式时,会遇到错误未捕获的错误:语法错误,无法识别的表达式:..帮助得到赞赏

How will i change the existing formulae to this? When i implement this formula, iam getting an error Uncaught Error: Syntax error, unrecognized expression: .. Help Appreciated

推荐答案

您的函数几乎正确,在"total1"之后只有一个多余"点

your function is almost right, you have only one "extra" dot after "total1"

您可以安全地更改

 var newTotal = currency==="INR" ? totalINR : (totalINR * conversionRate / row.find('.inrvalue').val()).toFixed(3);

var newTotal = 0;
        if (currency==="INR")
        {
            newTotal = totalINR; 
        } else if (currency==="USD")
        {
            newTotal = (row.find('.total1').val() *  row.find('.inrvalue').val());
        } else {
            newTotal = ((row.find('.inrvalue').val() / conversionRate) * row.find('.total1').val());
        }

希望这会有所帮助

这篇关于根据选定的下拉值循环进行jquery计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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