根据动态添加的字段计算值(Calculating values based on dynamically added fields)
我正在尝试基于字段创建动态聚合。 唯一的区别是它不是一个表格而是一个div区块。
我正在努力完成的
在按钮上单击添加字段,模板中的内容被克隆(就像表格行一样),这部分工作正常。
代码应该计算值,为每行添加一些字段。 我使用了密码功能来保持它随时更新。
为什么它不起作用?
那么我无法像这样工作。每个i_row或模板包含字段
p_cnetto[] p_pvat[] p_ilosc[]
(quantitiy)因为我不能阅读行 - 我尝试了很多东西,但显然做了一些坏事,它只计算curr_net的价值,它仍然不是它应该的方式。
十进制值应该是可以接受的:例2222.00
它应该如何工作?
- 添加一行
总结行部分[不需要显示行聚合]:
curr_netto =获得此行
p_cnetto[]
值乘以p_ilosc[]
curr_brutto =得到这一行
(p_cnetto[] * p_pvat[]) / 100 * p_ilosc[]
最后它应该计算所有行的总数total_netto,total_brutto - 可以在console.log中
感谢您的任何提示。
<!-- statistic block ---> <div id="curr_netto"></div> <div id="curr_brutto"></div> <button class="btn btn-primary btn-add-panel mt-5" type="button"> <i class="glyphicon glyphicon-plus"></i> Add field</button> <div class="row"> <div class="col-sm-12" id="extra_group"> <!-- s --> <div class="widget widget2 card template mb-2 bg-light-blue-50" style="display: none;"> <div class="col-lg-5"> <div class="row i_row"> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>Name</label> <input type="text" name="p_nazwa[]" class="form-control"></input> </div> </div> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>Qty</label> <input type="text" name="p_ilosc[]" class="form-control p_ilosc"></input> </div> </div> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>Unit</label> <select class="form-control" name="p_unit[]"> <option value="Kg">Kilogram</option> </select> </div> </div> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>Net</label> <input type="text" name="p_cnetto[]" class="form-control p_cnetto"></input> </div> </div> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>VAT</label> <input type="text" name="p_pvat[]" class="form-control p_pvat"></input> </div> </div> <div class="form-group col-md-2"> <div class="subtot"></div> </div> <div class="form-group col-md-2"> <button class="btn btn-danger btn-add-panel rh mt-5 ml-3"> <i class="glyphicon glyphicon-minus"></i> Del</button> </div> </div> </div> </div> <!-- s --> </div> </div>
I am trying to create a dynamic aggregation based on fields. The only difference is that it's not a table but a div block.
What I am trying to accomplish
On button click add field, the content from the template is cloned ( it's like a table row ), this part is fully working.
The code is supposed to count the values, for each row add some fields. I used keyup function to keep it updated all time.
Why is it not working?
Well I was not able to get it working like such .each of i_row or template contains fields
p_cnetto[] p_pvat[] p_ilosc[]
( quantitiy )Because I can't read row wise - I tried many things but apparently did something bad it only counts curr_net value and it's still not the way it should be.
Decimal values should be acceptable : example 2222.00
How it should work?
- Add a row
Summing row part [ not really need to display row aggregation ]:
curr_netto = get this row
p_cnetto[]
value multiply byp_ilosc[]
curr_brutto = get this row
(p_cnetto[] * p_pvat[]) / 100 * p_ilosc[]
At the end it should calculate a grand total of all rows for as total_netto,total_brutto - could be in console.log
Thanks for any tips.
<!-- statistic block ---> <div id="curr_netto"></div> <div id="curr_brutto"></div> <button class="btn btn-primary btn-add-panel mt-5" type="button"> <i class="glyphicon glyphicon-plus"></i> Add field</button> <div class="row"> <div class="col-sm-12" id="extra_group"> <!-- s --> <div class="widget widget2 card template mb-2 bg-light-blue-50" style="display: none;"> <div class="col-lg-5"> <div class="row i_row"> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>Name</label> <input type="text" name="p_nazwa[]" class="form-control"></input> </div> </div> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>Qty</label> <input type="text" name="p_ilosc[]" class="form-control p_ilosc"></input> </div> </div> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>Unit</label> <select class="form-control" name="p_unit[]"> <option value="Kg">Kilogram</option> </select> </div> </div> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>Net</label> <input type="text" name="p_cnetto[]" class="form-control p_cnetto"></input> </div> </div> <div class="form-group col-md-2"> <div class="form-group pmd-textfield pmd-textfield-floating-label"> <label>VAT</label> <input type="text" name="p_pvat[]" class="form-control p_pvat"></input> </div> </div> <div class="form-group col-md-2"> <div class="subtot"></div> </div> <div class="form-group col-md-2"> <button class="btn btn-danger btn-add-panel rh mt-5 ml-3"> <i class="glyphicon glyphicon-minus"></i> Del</button> </div> </div> </div> </div> <!-- s --> </div> </div>
原文:https://stackoverflow.com/questions/45633704
满意答案
这是基于导航的应用程序的默认后退按钮样式。 您可以在创建新应用程序时通过选择基于导航的应用程序来使用它。
创建应用程序后,您必须设置视图的标题。 该视图标题将是后退按钮的标题。 如果您没有上一个视图的标题,则后退按钮不会自动出现。
你可以像这样推送视图:
if (settingViewController == nil) { settingViewController = [[SettingViewController alloc] initWithNibName:@"SettingViewController" bundle:nil]; } [self.navigationController pushViewController:settingViewController animated:YES];
在这种情况下,navigationController已经由Xcode创建,您必须准备settingViewController(.h,.m,.xib)。
It is default back button style of Navigation-based application. You can use it by selecting Navigation-based application when creating new application.
After created the application, you must set title of the view. That view title will be the title of back button. If you have no title of previous view, the back button will not appear automatically.
You can push view like this:
if (settingViewController == nil) { settingViewController = [[SettingViewController alloc] initWithNibName:@"SettingViewController" bundle:nil]; } [self.navigationController pushViewController:settingViewController animated:YES];
In this case, navigationController is already created by Xcode and you must prepare settingViewController(.h, .m, .xib).
相关问答
更多如何在iPhone中获得这种后退按钮(How to get this kind of back button in iphone)
iPhone 6+没有导航栏后退按钮项(iPhone 6+ does not have navigation bar back button item)
iPhone如何获得自定义后退按钮的标题(iPhone how to get the title for a custom Back-Button)
如何在UINavigationController中按下后退按钮时调用viewDidLoad方法?(How to call viewDidLoad method when back button is pressed in UINavigationController? (iPhone / iPad))
如何在手机应用程序中处理iPhone上丢失的hw后退按钮?(How to deal with missing hw back button on iphone in a phonegap app?)
如何将navigationcontroller的后退按钮转换为iPhone中的浏览器后退按钮?(How to convert navigationcontroller's back button into browser's back button in iPhone?)
如何隐藏iPhone上第一个视图中的后退按钮?(How to hide back button in the first view on iPhone?)
如何禁用iPhone应用程序中的后退按钮(How to disable back button in iPhone Application)
iPhone SDK:自定义后退按钮标题(iPhone SDK: Customizing back button title)
导航控制器(iPhone)的后退按钮问题(Back Button Issues With Navigation Controller (iPhone))
相关文章
更多Storm 中 Fields作用
Java-based 实现的索引复制
Storm【设计细节】 -Fields对象
INSERT INTO blog_appitem (user_id,appid,app_secret,is_valid) VALUES (1, 'wxf415741de036114c','48e1e345fd5f11c93af18ff1714c7f78',1)
el表达式如何动态获得某一个字段的值?
Solr官方文档系列——Text Analysis
elasticsearch 添加字段
ibatis中如何配置,动态字段
[How to] Make custom search with Nutch(v 1.0)?(转)
Guava Booleans类-布尔型基本的实用工具类
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!