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. Android中一个类实现的接口数不能超过七个

    近期一段时间,在开发Android应用程序的过程中,发现Android中一个类实现的接口数超过七个的时候,常常会出现超过第7个之后的接口不能正常使用.

  2. 做web项目时对代码修改后浏览器端不生效的应对方法(持续更新)

    做web项目时,经常会遇到修改了代码,但浏览器端没有生效,原因是多种多样的,我会根据我遇到的情况逐步更新解决办法 1.运行的时候采用debug模式,一般情况下使用项目部署按钮右边那个按钮下的tomca ...

  3. HDU ACM 4578 Transformation-&gt;段树-间隔的变化

    分析:复杂的经营分部树. 只有一个查询操作,这是要求[l,r]的数量之间p钍总和.并不是所有的查询所有节点,会议TLE.最好的是查询部件[a.b].所有这个区间值我们是平等的,即能返回(b-a+1)* ...

  4. Mahout推荐算法ItemBased

    Mahout推荐的ItemBased 一.   算法原理 (一)    基本的 下面的例子,参见图评分矩阵:表现user,归类为item. 图(1) 该算法的原理: 1.  计算Item之间的相似度. ...

  5. 请注意CSDN社区微通道,许多其他的精彩等着你

    CSDN社区微信公众号"程序人生"(微信ID:coder_life)来了,每天我们会将CSDN社区中大量的优质内容浓缩成1~3篇文章.推送到您的手机中,让您不管何时何地都能感受到知 ...

  6. C++编程有趣的标题1 于1~9填写的运算结果的中间符号等于100

    于1 2 3 4 5 6 7 8 9将九个数字"+"要么"-"符号使得结果100,编程的所有组合. 注意:数字顺序不能改变 <pre name=" ...

  7. Chapter 1 Securing Your Server and Network(3):使用托管服务帐号

    原文:Chapter 1 Securing Your Server and Network(3):使用托管服务帐号 原文出处:http://blog.csdn.net/dba_huangzj/arti ...

  8. c++输入密码以星号代替

    #include <iostream> #include <string>//注意这里的头文件! #include<conio.h> using namespace ...

  9. 单链表---java实现

    单链表优点:1.不需要预先给出元素个数. 2.单链表插入删除时不需要移动数据元素. 单链表缺点:1.每个节点有指针,空间利用率低. 2.单链表不支持随机读取数据. Node.java package ...

  10. 第十七章——配置SQLServer(3)——配置“对即时负载的优化”

    原文:第十七章--配置SQLServer(3)--配置"对即时负载的优化" 前言: 在第一次执行查询或者存储过程时,会创建执行计划并存储在SQLServer的过程缓存内存中.在很多 ...