简体   繁体   English

"使用 JavaScript 的增值税计算器"

[英]VAT Calculator using javascript

I want to create a VAT calculator where the user enters an amount and the amount is multiplied by 1.15 (assume VAT is 15%) and alert message displays the results.我想创建一个增值税计算器,用户在其中输入金额,金额乘以 1.15(假设增值税为 15%),然后警报消息显示结果。 So if the user enters an amount of £500, then the alert message should display £575.因此,如果用户输入的金额为 500 英镑,则警报消息应显示为 575 英镑。

 function mult(x) { if (x.length == 0) { alert("Numbers cannot be blank"); return; } if (isNaN(x)) { alert("Value entered is not numeric"); return; } var result = parseInt(x) * 1.15; alert("Multiplication: " + result); }<\/code><\/pre>
 <h1>VAT Calculator<\/h1><br> Amount(£): <input type="text" id="amount" name="txt_amount"> <br><br> <button onclick="calculateVAT(amount.value)">Calculate Total Amount<\/button><\/code><\/pre>

The code of for the javascript is not working.Can you please help me. javascript的代码不起作用。你能帮帮我吗? Thanks.谢谢。

"

Rename your function from mult to function calculateVAT(x)将您的函数从mult重命名为function calculateVAT(x)

 function calculateVAT(x) { if (x.length == 0) { alert("Numbers cannot be blank"); return; } if (isNaN(x)) { alert("Value entered is not numeric"); return; } var result = parseInt(x) * 1.15; alert("Multiplication: " + result); }
 <h1>VAT Calculator</h1><br> Amount(£): <input type="text" id="amount" name="txt_amount"> <br><br> <button onclick="calculateVAT(amount.value)">Calculate Total Amount</button>

The error is occurring because when the button is clicked, the code is looking for a function called calculateVAT() which does not exist in the JS.发生错误是因为当单击按钮时,代码正在查找 JS 中不存在的名为 calculateVAT() 的函数。

To resolve the issue, either rename your function called mult() to calculateVAT() or change onClick in the button tag to call the mult() function rather then calculateVAT()要解决此问题,请将名为 mult() 的函数重命名为calculateVAT() 或更改按钮标记中的onClick 以调用mult() 函数而不是calculateVAT()

Calculate Total Amount计算总金额

I think you need to sign in again or delete the captcha I also faced the same issue while creating my calculator lens but then I solved it by doing the same thing.我认为您需要重新登录或删除验证码我在创建计算器镜头时也遇到了同样的问题,但后来我通过做同样的事情解决了这个问题。 these details https:\/\/www.vatcalculator.info\/ireland\/<\/a>这些详细信息https:\/\/www.vatcalculator.info\/ireland\/<\/a>

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM