作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们并不总是需要在订单中加税,因此我需要一种默认情况下绕过税费的方法,除非另有说明。
所以我有以下文本框:
<input class="txt1" type="text" name="subtotal" value="" id="subtotal"
size="16" tabindex="42" onChange="enableBeforeUnload();"
onKeyUp="enableBeforeUnload();">
我的这个文本框工作正常 - 它对值进行求和。
我有两个文本框,我试图将它们乘以税率并显示总计:
<input class="txt1" type="text" name="tax" id="tax" value="1" size="16" tabindex="42"
onChange="enableBeforeUnload();" onKeyUp="enableBeforeUnload();">
<input class="txt2" type="text" name="total1" value="" id="total1" size="16"
tabindex="42" onChange="enableBeforeUnload();" onKeyUp="enableBeforeUnload();">
我尝试使用以下命令,但没有成功:
var tax = +$("#tax").val(), // get tax and convert to a number
total = tax ? sum * tax : sum; // if tax is a non-zero number multiply
// otherwise just take the sum as is
还有这个:
totAmt.val(sum + sum*parseFloat(taxAmt.val()/100));
我无法正确实现。提前致谢。
http://jsfiddle.net/thetylercox/jh2Ne/7/我无法让它正常工作 http://soldbybillcox.com/treasure/demo.php它在这里工作正常
最佳答案
对于初学者,您正在调用:
$("#tax")
但是您没有带有税号的元素。你可以使用:
$("input[name=tax]")
-编辑->那么问题是获取值,还是计算总数的逻辑?您可以将税务逻辑放入函数中:
function getTax(tax){
var taxFloat = parseFloat(tax)
if(isNaN(taxFloat)){
return 1;
}else{
return taxFloat;
}
}
然后使用:
total = getTax($('#tax').val()) * sum;
关于javascript - 乘以税收并添加到总额中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11546743/
需要一个良好且灵活的数据库模式来说明电子商务产品及其费率管理。 最佳答案 我同意 Chris Roberts,OSCommerce是一个很好的起点以及DatabaseAnswers.org . 希望对
这个问题之前有人问过here但没有人给用户一个答案。我也遇到了同样的情况,请问有大神解答过吗? 问题又来了: “我是 iOS 的新手,正在构建一个具有应用内购买功能的应用。该应用尚未准备好(不在应用商
我是一名优秀的程序员,十分优秀!