jQuery能够计算的表单,包含单选改变价格,select改变价格,动态加入删除行计算

各种表单情况的计算

JavaScript Code
  1. <script type="text/javascript">
  2. var currentRow = 3;
  3. $(document).ready(function(){
  4. $('#calx').calx();
  5. $('#add_item').click(function(){
  6. var $calx = $('#calx');
  7. currentRow++;
  8. $calx.append('<tr>\
  9. <td><input type="text" id="A'+currentRow+'" value="" /></td>\
  10. <td><input type="text" id="B'+currentRow+'" value="" data-format="$ 0,0[.]00" /></td>\
  11. <td><input type="text" id="C'+currentRow+'" value="" data-format="0" /></td>\
  12. <td><input type="text" id="D'+currentRow+'" value="" data-format="0[.]00 %" /></td>\
  13. <td><input type="text" id="E'+currentRow+'" value="" data-format="$ 0,0[.]00" data-formula="($B'+currentRow+'*$C'+currentRow+')*(1-$D'+currentRow+')" /></td>\
  14. <td><input type="button" value="remove" class="btn-remove" /></td>\
  15. </tr>');
  16. //update total formula
  17. $('#F1').attr('data-formula','SUM($E1,$E'+currentRow+')');
  18. $calx.calx('refresh');
  19. });
  20. $('#calx').on('click', '.btn-remove', function(){
  21. $(this).parent().parent().remove();
  22. $('#calx').calx('refresh');
  23. });
  24. });
  25. </script>
XML/HTML Code
  1. <table id="calx" width="80%" align="center">
  2. <thead>
  3. <tr>
  4. <td style="width:250px">Item Name</td>
  5. <td style="width:150px">Item Price</td>
  6. <td style="width: 50px">Qty</td>
  7. <td style="width: 80px">Discount</td>
  8. <td style="width:150px">Sub Total</td>
  9. <Td></Td>
  10. </tr>
  11. </thead>
  12. <tbody id="itemlist">
  13. <tr>
  14. <td><input type="text" id="A1" value="HDD Baracuda Black 2TB" /></td>
  15. <td><input type="text" id="B1" value="" data-format="$ 0,0[.]00" /></td>
  16. <td><input type="text" id="C1" value="" data-format="0" /></td>
  17. <td><input type="text" id="D1" value="" data-format="0[.]00 %" /></td>
  18. <td><input type="text" id="E1" value="" data-format="$ 0,0[.]00" data-formula="($B1*$C1)*(1-$D1)" /></td>
  19. <td><input type="button" value="remove" class="btn-remove" /></td>
  20. </tr>
  21. <tr>
  22. <td><input type="text" id="A2" value="BenQ LED Monitor 21 inch" /></td>
  23. <td><input type="text" id="B2" value="" data-format="$ 0,0[.]00" /></td>
  24. <td><input type="text" id="C2" value="" data-format="0" /></td>
  25. <td><input type="text" id="D2" value="" data-format="0[.]00 %" /></td>
  26. <td><input type="text" id="E2" value="" data-format="$ 0,0[.]00" data-formula="($B2*$C2)*(1-$D2)" /></td>
  27. <td><input type="button" value="remove" class="btn-remove" /></td>
  28. </tr>
  29. <tr>
  30. <td><input type="text" id="A3" value="Intel Processor i3 2328" /></td>
  31. <td><input type="text" id="B3" value="" data-format="$ 0,0[.]00" /></td>
  32. <td><input type="text" id="C3" value="" data-format="0" /></td>
  33. <td><input type="text" id="D3" value="" data-format="0[.]00 %" /></td>
  34. <td><input type="text" id="E3" value="" data-format="$ 0,0[.]00" data-formula="($B3*$C3)*(1-$D3)" /></td>
  35. <td><input type="button" value="remove" class="btn-remove" /></td>
  36. </tr>
  37. </tbody>
  38. <tfoot>
  39. <tr>
  40. <td colspan="4" style="text-align: right">Total Price :</td>
  41. <td id="F1" data-format="$ 0,0[.]00" data-formula="SUM($E1,$E3)"></td>
  42. <Td></Td>
  43. </tr>
  44. </tfoot>
  45. </table>
  46. <input type="button" value="Add new item" id="add_item" />

原文地址:http://www.freejs.net/article_biaodan_155.html

jQuery形式可以计算,它包含了无线电的变化价格,select价格变化,删除行动态计算加盟的更多相关文章

  1. Jquery判断数组中是否包含某个元素$.inArray()的用法

    判断数组里面是否包含某个元素可以使用 $.inArray("元素(字符串)",数组名称) 进行判断 ,当存在该元素(字符串)时,返回该元素在数组的下标,不存在时返回 -1 示例代码 ...

  2. 【Java】一个小程序,计算它包含的代码所需的耗时

    写一个小程序,用来计算它包含的代码所需的耗时.虽然简单,测试代码是否耗时还是有点用的,不用重新写嘛~ import java.util.Date; import java.util.concurren ...

  3. jquery判断一个标签是否包含另外一个标签

    jquery判断一个标签是否包含另外一个标签 一.总结 一句话总结: jquery的find方法配合length属性:if($("#video_md_9_1").find(&quo ...

  4. iOS 动态计算文本内容的高度

    关于ios 下动态计算文本内容的高度,经过查阅和网上搜素,现在看到的有以下几种方法: 1. //  获取字符串的大小  ios6 - (CGSize)getStringRect_:(NSString* ...

  5. 计算概论(A)/基础编程练习2(8题)/2:计算书费

    #include<stdio.h> int main() { // 声明与初始化 ; // k组测试数据的总费用 double s[k]; // 单价表 double price[]= { ...

  6. 动态计算UITableViewCell高度

    动态计算UITableViewCell高度 UILabel in UITableViewCell Auto Layout - UILabel的属性Lines设为了0表示显示多行.Auto Layout ...

  7. 动态计算Label高度

    //1.设置该label的numberOfLines为0 self.titleLabel.numberOfLines = 0;    //2.字体的设置要与之前相同 NSDictionary * at ...

  8. 还能输入多少字?(JS动态计算)

    <div class="m-form ovh"> <div class="hd"> <span class="fr&qu ...

  9. iOS学习之根据文本内容动态计算文本框高度的步骤

    在视图加载的过程中,是先计算出frame,再根据frame加载视图的,所以在设计计算高度的方法的时候,设计成加号方法; //首先给外界提供计算cell高度的方法 + (CGFloat)heightFo ...

随机推荐

  1. svn创建并应用补丁

    有时,我们不能提交临时局部变化,而我们需要回滚到svn最新的版本号.然,这些变化,我们要保持.提交或发送给其他同事的未来review. 怎么做?非常easy,只需要两个步骤: (1)创建一个补丁文件并 ...

  2. uva 10192 Vacation(最长公共子)

    uva 10192 Vacation The Problem You are planning to take some rest and to go out on vacation, but you ...

  3. [TWRP 2.8.4 ] 小米 3W 中文-英文版本 twrp

    经过半个小时的代码修改,从 2.7.0 移植到 2.8.4 的源代码上. 汉化操作是使用切换语言选项来实现的. 注意: 此版本的 twrp 还不支持双系统切换功能. 作者:laser杨万荣 如果需要转 ...

  4. LeerCode 123 Best Time to Buy and Sell Stock III之O(n)解法

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  5. table 谷歌下不出现滚动条

    <table> </table> <style> table {overflow-y:scroll;max-height:152px; height:auto;} ...

  6. 【UVA272】TEX Quotes

    A - TEX Quotes Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %llu Submitcid=80 ...

  7. ViewRootImpl和WindowManagerService笔记

    1.每个窗体的ViewRootImpl都有一个mWindowAttributes窗体属性,该属性在WindowManagerGlobal.updateViewLayout()->ViewRoot ...

  8. PDE_DATA 定义

    PDE_DATA 定义 Location: /fs/proc/internal.h static inline struct proc_dir_entry *PDE(const struct inod ...

  9. [Linux]scp 命令远程复制

    这些天来干预系统之前没有接触,建立使用用途良好的发展环境 scp命令,那么如何使用查询以下信息. scp是secure copy的缩写.主要用来linux系统之间的文件和文件夹的远程拷贝 能够非常ea ...

  10. 如何插上U盘 自动复制内容

    U盘插入自动复制,有效对付那些不肯给PPT的老师,还有一定几率拿到期末考试卷子···有图有真相!业界良心的好东西!!现在看还来得及!!! 代码优化了一下,把不是很重要的都删掉了,这次使用时看不出任何现 ...