Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我不明白为什么我的html页面没有运行我的外部javascript文件_Javascript_Html_Atom Editor - Fatal编程技术网

我不明白为什么我的html页面没有运行我的外部javascript文件

我不明白为什么我的html页面没有运行我的外部javascript文件,javascript,html,atom-editor,Javascript,Html,Atom Editor,我有两个名为CalculateFV()的javascript函数,用于通过获取processEntries()函数的输入来计算我的未来值,然后在HTML页面上的“未来值”文本框中显示结果,但我目前无法理解为什么它不能正常工作,并且按钮无法计算我的结果 我还使用atom作为我的编辑器 未来价值计算器 未来价值计算器 总投资: 年利率: % 年数: 未来价值: var$=函数(id){ 返回文档.getElementById(id); }; var calculateFV=函数(投资金额

我有两个名为CalculateFV()的javascript函数,用于通过获取processEntries()函数的输入来计算我的未来值,然后在HTML页面上的“未来值”文本框中显示结果,但我目前无法理解为什么它不能正常工作,并且按钮无法计算我的结果 我还使用atom作为我的编辑器


未来价值计算器
未来价值计算器
总投资:

年利率: %
年数:
未来价值:

var$=函数(id){
返回文档.getElementById(id);
};
var calculateFV=函数(投资金额、利率、年数){
var未来价值;
未来价值=投资额

对于(var i=1;i未正确处理
onLoad
函数,您需要注册
侦听器,单击“计算”按钮。请尝试以下操作:

future\u value.js:

"use strict";
var $ = function(id) {
    return document.getElementById(id);
};

var calculateFV = function(investment_amount, interest_rate, number_of_years){
  var futureValue;
  futureValue = investment_amount
  for(var i = 1; i <= number_of_years; i++){
    futureValue = futureValue + (futureValue * interest_rate / 100);
  }
  return futureValue;
}

var processEntries = function(){
  var investment_amount = $("investment").value;
  var interest_rate = $("rate").value;
  var number_of_years = $("years").value;

  $("future_value").value = calculateFV(investment_amount, interest_rate, number_of_years);
}

window.addEventListener('load', (event) => {
  $('calculate').addEventListener('click', processEntries);
  $("investment").focus();
});
“严格使用”;
var$=函数(id){
返回文档.getElementById(id);
};
var calculateFV=函数(投资金额、利率、年数){
var未来价值;
未来价值=投资额
对于(var i=1;i{
$('calculate')。addEventListener('click',processEntries);
$(“投资”).focus();
});
使用此选项,我可以看到单击“计算”后填充的未来值输入。请注意我在底部所做的更改

     var $ = function(id) {
            return document.getElementById(id);
        };
        
        var calculateFV = function(investment_amount, interest_rate, number_of_years){
          var futureValue;
          futureValue = investment_amount
          for(var i = 1; i <= number_of_years; i++){
            futureValue = futureValue + (futureValue * interest_rate / 100);
          }
          return futureValue;
        }
        
        var processEntries = function(){
          var investment_amount = $("investment").value;
          var interest_rate = $("rate").value;
          var number_of_years = $("years").value;
        
          $("future_value").value = calculateFV(investment_amount, interest_rate, number_of_years);
        }
        
        window.onLoad = function(){
          $("calculate").value = processEntries;
          $("investment").focus();
        }

"use strict";
var $ = function(id) {
    return document.getElementById(id);
};

var calculateFV = function(investment_amount, interest_rate, number_of_years){
  var futureValue;
  futureValue = investment_amount
  for(var i = 1; i <= number_of_years; i++){
    futureValue = futureValue + (futureValue * interest_rate / 100);
  }
  return futureValue;
}

var processEntries = function(){
  var investment_amount = $("investment").value;
  var interest_rate = $("rate").value;
  var number_of_years = $("years").value;

  $("future_value").value = calculateFV(investment_amount, interest_rate, number_of_years);
}

window.addEventListener('load', (event) => {
  $('calculate').addEventListener('click', processEntries);
  $("investment").focus();
});