我正在为学生设计一个学费计算器,并在更改年份时将#variable选项每次选择为Variable(继承的代码,而不是我的名字选择),以更新当前年份,输出重复所有的费用。我已经修改了功能和代码,此问题出在哪里?
(我当前的版本有问题:https://tarleton.edu/scripts/tuitioncal/default-trial.asp) 起初我以为是一年一度的问题,但是在阅读了以前的文档之后,我对其进行了更正,但问题仍然存在。
我假设问题在这里出现,并且通过if / else语句运行了两次,尽管信息没有改变:
$('input#submit').click(function() {
var currentDate = new Date();
var currentYear = currentDate.getFullYear(); //Currently in the middle of
the academic year, so the adjustment had to be made.
var adjustedYear = 0;
var adjustmentForYear = 0;
if ($('select#semester option:selected').hasClass('current-academic-year')){ adjustmentForYear = parseInt(-1); }
else if ($('select#semester option:selected').hasClass('future-academic-year')) { adjustmentForYear = parseInt(0); }
else if ($('select#semester option:selected').hasClass('last-year')) { adjustmentForYear = parseInt(-2); }
if ($("select#variable option:selected").val() != "variable" || $('select#classification option:selected').val() == "4")
{
//Handles ALL Guaranteed Tuition Plans and Graduate Plan
adjustedYear = (parseInt($('select#semester option:selected').val()) +
adjustmentForYear - $('select#classification option:selected').val());
}
else
{ //Handles Variable Tuition Plans for Freshmen, Sophomores, Juniors, and Seniors
adjustedYear = currentYear + adjustmentForYear;
}
我希望包括大学服务费在内的非重复输出为91.66美元,但请参阅大学服务费:991.66美元和117.89美元。