function newBusRoute() {
busRoute += 1;
routeName = "Bus Route " + busRoute;
routeArrayBusRoutes.push(routeName);
vehArrayBusRoutes.push(0);
updateRoutes(routeArrayBusRoutes, vehArrayBusRoutes, "busRoutesListDiv", 600, "maintBus", maintBus, 99, 50, "vehCountBus");
}
function updateRoutes(routeArray, vehArray, listid, cost, maintType, maintCost, eivPlus, capacityPlus, vehCountType) {
document.getElementById(listid).innerHTML = "";
for (I in routeArray) {
document.getElementById(listid).innerHTML += ("<button onclick='editRoute(\""+I+"\", \""+vehArray[I]+"\", \""+vehArray+"\", \""+cost+"\", \""+maintType+"\", \""+maintCost+"\", \""+eivPlus+"\", \""+capacityPlus+"\", \""+vehCountType+"\")'>"+routeArray[I]+"</button>");
}
}
function editRoute(route, vehCount, vehArray, cost, maintType, maintCost, eivPlus, capacityPlus, vehCountType) {
$("#mainContainer").fadeOut();
document.getElementById("screen").innerHTML = (
"<h1>Bus Route "+route+"</h1>" +
"<p id='routeVehCount'>Vehicles on this route: "+vehCount +
"<p><button onclick='addVeh(\""+route+"\", \""+vehArray+"\", \""+cost+"\", \""+maintType+"\", \""+maintCost+"\", \""+eivPlus+"\", \""+capacityPlus+"\", \""+vehCountType+"\")'>+ Add Vehicle | Cost: £600 | Maintenance: £50 per day</button>"
);
$("#screen").fadeIn();
$("#closeButton").fadeIn();
}
function addVeh(route, vehArray, cost, maintType, maintCost, eivPlus, capacityPlus, vehCountType) {
vehArray[route] += 1;
vehCountType += 1;
bank -= cost;
checkBank;
maintCost = Number(maintCost);
maintType += maintCost;
checkIncome();
eiv = Number(eiv);
eiv += Number(eivPlus);
checkEIV();
capacity = Number(capacity);
capacity += capacityPlus;
checkCapacity();
}
Привет, я написал эти функции. Я знаю, что они выглядят грязно, но по существу все переменные передаются по функциям от updateRoutes()
до addVeh()
. Все они работают нормально, кроме "vehCountBus"
, который передается как vehCountType
. Не выдается никаких ошибок, оно просто не обновляется, если я вручную не заменю vehCountType
в addVeh()
на vehCountBus
.
Почему значение vehCountType
не передается, как другие переменные?