duanqiangwu9332 2019-08-05 09:45
浏览 42

如何获取特定行Dropdown或Radio按钮通过动态使用JQuery创建的值

I want to give product wise discount in my invoice application. I used to create dynamic row using jquery.invoice.js plugin. I have to get Discount type which is in percentage either amount. I can't get that discount type. There is any way to get that discount type and calculate the discount of each product?

I have tried to store that click events to array and fetch into that calculation. But it stores repeated values by clicks.

newRow: function () {
        jQuery(".item-row:last").after('<tr class="item-row"><td class="item-name"><div class="delete-btn"><a class=' + $.opt.delete.substring(1) + ' href="javascript:;" title="Remove row">X</a><input type="text" class="form-control item custom-width" placeholder="Product Name" type="text" name="name[]"></div></td><td><input class="form-control price" placeholder="Price" type="text" name="price[]"></td><td><input class="form-control qty" placeholder="Quantity" type="text" name="quantity[]"></td><td><input type="radio" name="discountType" class="discountType" id="discountType" value="percentage">%<input type="radio" name="discountType" class="discountType" id="discountType" value="amount">&#8377;<input class="form-control discount" placeholder="Value" class="value" type="text" name="discount"></td><td align="right"><span class="total">0.00</span></td></tr>');
        if (jQuery($.opt.delete).length > 0) {
            jQuery($.opt.delete).show();
        }

        return 1;
    },

and total of each product function is

calcTotal: function () {
         jQuery($.opt.parentClass).each(function (i) {
             var row = jQuery(this);
             var total = row.find($.opt.price).val() * row.find($.opt.qty).val();
             total = self.roundNumber(total, 2);
             row.find($.opt.total).html(total);
         });

         return 1;
     },

Please help me to get the discount type and calculate it to same row's product. Thanks in Advance.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题
    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体