JavaScript 问题
我正在尝试用 Javascript 制作一个计算器,但遇到了一些问题...... 代码位于 http://jsfiddle.net/NwkQW/10/。
- 尝试添加一些值,您将看到显示 TOTAL 的框将根据您输入的值而变化。 但是,您还会看到,如果单击“CLEAR FORM”,该值将不会返回到“TOTAL”。我该怎么做?
- 我想链接到 javascript(例如
!
I am trying to make a calculator with Javascript, and I'm having a few problems...
The code is at http://jsfiddle.net/NwkQW/10/.
- Try adding some values, and you'll see that the box that says TOTAL will change according to the values you enter. However, you'll also see that if you click CLEAR FORM, the value will not go back to TOTAL. How do I do that?
- I want to link to the javascript (e.g.
<script type="text/javascript" src="mydomain.com/calculate.js></script>
), but if I try, it doesn't work right! HELP!!!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
添加 onClick 到您的清除表单按钮,例如:
重置不会清除任何不是表单元素的内容,
请参阅 http:// jsfiddle.net/NwkQW/16/
add a onClick to your clear form button like:
reset won't clear anything that's not a form element
see http://jsfiddle.net/NwkQW/16/
添加 http://www。到源的开头。您正在尝试访问 http://www.mydomain.com/mydomain.com/calculate .js 假设该文件位于 /
Add http://www. to the beginning of your source. You are trying to go to http://www.mydomain.com/mydomain.com/calculate.js assuming this file lives at /
只需将您的
totalDiv
更改为输入元素,它就会与其他所有内容一起被清除。或者,不要依赖表单重置,而只需清除方法中的所有内容。Just change your
totalDiv
to an input element and it will get cleared along with everything else. Or, don't rely on form reset and just clear everything in a method.