`

jQuery可以计算的表单,包括单选改变价格,select改变价格,动态添加删除行计算

 
阅读更多

各种表单情况的计算

jQuery可以计算的表单,包括单选改变价格,select改变价格,动态添加删除行计算

 

 

JavaScript Code
  1. <script type="text/javascript">  
  2. var currentRow = 3;  
  3. $(document).ready(function(){  
  4.     $('#calx').calx();  
  5.       
  6.     $('#add_item').click(function(){  
  7.         var $calx = $('#calx');  
  8.         currentRow++;  
  9.           
  10.         $calx.append('<tr>\ 
  11.             <td><input type="text" id="A'+currentRow+'" value="" /></td>\ 
  12.             <td><input type="text" id="B'+currentRow+'" value="" data-format="$ 0,0[.]00" /></td>\ 
  13.             <td><input type="text" id="C'+currentRow+'" value="" data-format="0" /></td>\ 
  14.             <td><input type="text" id="D'+currentRow+'" value="" data-format="0[.]00 %" /></td>\ 
  15.             <td><input type="text" id="E'+currentRow+'" value="" data-format="$ 0,0[.]00" data-formula="($B'+currentRow+'*$C'+currentRow+')*(1-$D'+currentRow+')" /></td>\ 
  16.             <td><input type="button" value="remove" class="btn-remove" /></td>\ 
  17.         </tr>');  
  18.           
  19.         //update total formula  
  20.         $('#F1').attr('data-formula','SUM($E1,$E'+currentRow+')');  
  21.         $calx.calx('refresh');  
  22.     });  
  23.   
  24.     $('#calx').on('click''.btn-remove'function(){  
  25.         $(this).parent().parent().remove();  
  26.         $('#calx').calx('refresh');  
  27.     });  
  28. });  
  29.    </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

0
3
分享到:
评论

相关推荐

    jquery获取input表单值的代码

    jquery取radio单选按钮的值$(“input[name=’items’]:checked”).val();jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关 获取一组radio被选中项的值 var item = $(...

    jQuery下拉美化搜索表单样式代码.zip

    JQuery下拉美化搜索表单样式代码是一款美化下拉框的表单,兼容IE6浏览器,样式已写好,需要的朋友改一下就可以用了。

    select,radio 表单回显避免使用jquery载入赋值 .txt

    select,radio 表单回显避免使用jquery载入赋值

    jQuery单选框和复选框美化代码.zip

    jQuery单选框和复选框美化代码是一款基于ui-choose.js实现的表单单选框,复选框美化插件,支持原生select标签和ul标签美化,并且能很方便的获取选中的值。

    jQuery表单元素美化插件jqtransform.zip

    Query表单元素美化插件jqtransform是一款非常实用,可以美化文本框,checkbox复选框,radio单选框,select下拉框等。

    jQuery form表单美化实例代码

    jQuery form表单美化实例代码,input输入框,select下拉框,复选框,单选框等表单元素美化特效。

    【开源】jQuery oform beta 0.1.5 - form 表单美化插件源代码

    jQuery oform beta 0.1.5 - form 表单美化插件源代码 版权:zhang yang soft 交流E-Mail:oceancode@163.com 浏览器支持:IE、Firefox、Opera , google chrome (谷歌) 版本说明: 1. beta 0.1.0 版 支持input...

    jQuery实现select下拉框样式美化效果

    内容索引:脚本资源,jQuery,Select,下拉框美化 jQuery实现select下拉框样式美化效果,这是个挺实用的网页美化技巧,现在jquery很流行,用它不但可以实现交互的Ajax效果,同时也可用来美化表单元素,像下拉框,单选框...

    select3是一款基于jQuery或Zeptojs的轻量级模块化select下拉列表框插件

    select3是一款基于jQuery或Zepto.js的轻量级模块化select下拉列表框插件。select3下拉列表框可以进行单选、以tag的形式进行多选、可以指定输入类型格式、可以进行分组选择、还可以ajax进行远程调用。

    jquery获取元素值的方法(常见的表单元素)

    jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关 获取一组radio被选中项的值 var item = $(‘input[name=items][checked]’).val(); 获取select被选中项的文本 var ...

    jQuery Mobile框架中的表单组件基础使用教程

    一.表单组件基础 1.组件简介 jQuery Mobile 中的表单组件是基于标准 HTML ...(1)文本输入框, type=”text” 标记的 input 元素会自动增强为 jQuery Mobile 样式,无需额外添加 data-role 属性。 (2)文本输入域, t

    JQuery&CSS;&CSS;+DIV实例大全.rar

    3.jQuery表单验证插件EasyValidator 2.0带TIP提示效果 4.jQuery导航插件下载之支持三级的Menu暖色、动画、折叠功能的导航菜单 5.jquery美化CheckBox的插件下载 6.jQuery美化表单漂亮插件jqtransform下载 7....

    jQuery设置和获取select、checkbox、radio的选中值方法

    select、checkbox、radio是很常用的表单控件,这篇文章主要介绍了jQuery设置和获取select、checkbox、radio的选中值方法,有兴趣的可以了解一下。

    jQuery攻略.pdf

    并且可以设置每页的行数 269 9.2 为图片添加注解 271 9.3 拖放表格中的行 273 9.4 取得、序列化并清理表单控件 275 9.5 通过Ajax提交表单 277 9.6 找到元素的准确位置和大小 281 9.7 以传送带的方式显示图片 284 9.8...

    【开源】jQuery oform beta 0.1.7 - form 表单美化插件源代码

    select单选,支持 Firefox、Opera , google chrome (谷歌) 时间: 2010-2-4 7. beta 0.1.6 版 支持 reset 按钮 刷新 radio / checkbox / select 优化核心代码 时间: 2010-2-6 8. beta 0.1.7 版 支持"组织机构代码"校验...

    Jquery 获取表单text,areatext,radio,checkbox,select值的代码

    jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关 获取一组radio被选中项的值 var item = $(‘input[@name=items][@checked]’).val(); 获取select被选中项的文本 var ...

    jQuery oform beta 0.1.3 - form 表单美化插件源代码

    支持input radio 单选按钮美化 时间:2010-01-26 3. beta 0.1.2 版 支持input checkbox 多选按钮美化 修改、优化核心代码 时间:2010-01-28 4. beta 0.1.3 版 支持 select 优化部分代码 时间:2010-01...

    jQuery表单美化实例代码

    jQuery表单美化实例代码是一款制作input输入框,select下拉框,复选框,单选框表单美化实例代码。

    jQuery获取和设置表单元素的方法

    jQuery提供了val()方法,使用它我们可以快速地获取和设置表单的文本框、单选按钮、以及单选按钮的值。使用val()不带参数,表示获取元素的值使用val()给定参数,则表示把值赋给元素 如下: 代码如下://获取值alert&#...

    jQuery表单美化插件jqTransform使用详解

    jQuery Form表单美化插件jqTransform,非常实用的jQuery插件,自动把你整个Form表单进行美化处理,包括SELECT下拉框、文本框、单选、复选框、按钮等,当然不支持input file文件选择框,这个可以参照我们之前的input ...

Global site tag (gtag.js) - Google Analytics