Javascript/Ajax/Jquery 动态计算表单变化
我有一个小表单,将由 Mysql 和人工输入填充。我想做的是根据其他字段填充其他 3 个字段。
示例:
总零件(Mysql)
劳动力(用户)
杂项(用户)
小计(上述动态总计)
税收(上述动态计算 - sub * 13%)
总计(子+税)
我已经搜索过但无法完全找到我正在寻找什么,而且我在 Javascript/Ajax/Jquery 方面的技能为零,所以我无法修改任何东西来工作,尽管我尝试得很惨。
有人可以帮助我解决这个问题,或者向我指出一个可能适合我需要的脚本。
谢谢
I have a small form which is going to be populated from Mysql and human input. What I want to do is populate 3 other fields based on the other ones.
Example:
Total Parts (Mysql)
Labor (User)
Misc (User)
Sub Total (Dynamic total of above)
Tax (Dynamic calc of above - sub * 13%)
Total (Sub + Tax)
I have searched around but can not quite find what I am looking for, and my skills are zero in Javascript/Ajax/Jquery so I haven't been able to modify anything to work, although I have tried miserably.
Can someone help me out on this or point me to a script that may suit my needs.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,抱歉,我以为您正在寻找一些复杂的代码。这是您正在寻找的内容的一个简单示例。
显然这并没有从数据库中获取动态值。如果您使用 PHP,您可以将这一行: 换成
这样的:
其中 getTotalParts.php 是您为获取数据库信息而创建的文件。它可以简单地获取信息并执行“echo $totalParts;”
Alright sorry, I thought you were looking for some complex code. Here is a simple example of exactly what you're looking for.
Obviously this doesn't grab the dynamic value from a database. If you use PHP you can swap this line:
for one like this:
Where the getTotalParts.php is a file you make to get your database information. It can simply grab the information and do a "echo $totalParts;"
您可以仅使用 onblur (当用户离开每个输入字段时激活)来计算字段。
您没有提供足够的信息来对“零件总数”字段发表评论。
You can just use onblur (activated when a user leaves each of the input fields) to calcuate the fields.
You haven't provided enough information to comment on the "Total Parts" field.