このコードに問題があります。プログラミングにまったく慣れていないため、何が間違っているのかわかりません。関数がWebブラウザーから実行されると、オブジェクトが期待されると表示されますが、コードを追加して削除する前に機能しました
これを投稿する場所が間違っていたらごめんなさい
function ratech01(){
var numcars = document.getElementById('numars').value;
var romcars = document.getElementById('removecars').value;
var addcars = document.getElementById('addcars').value;
var veh = 0;
var addveh = 0;
var removed = 0;
var Decision = '<span style="color:green">OK</span>';
var addloading = "(";
var busload = 0;
var inputload = +document.getElementById('load').value;
for (var i = 0; i < numcars; i++){
veh = +veh + +document.getElementById('carval' + i).value;
}
for (var i = 0; i < romcars; i++){
remove = +remove + +document.getElementById('romcarval' + i).value;
}
for (var i = 0; i < addcars; i++){
addveh = +addveh + +document.getElementById('addcarval' + i).value;
}
var addveh = addveh / 1000 * 5;
var remove = remove / 1000 * 5;
veh = veh / 1000 * 5;
vehend = veh + remove;
if (addveh != NaN || remove != NaN){
if ( addveh != NaN && remove != NaN){
addveh = veh + addveh - remove;
}else if( addveh != NaN){
addveh = veh - remove;
}else{
addveh = veh + addveh;
}
}else {
}
if ( document.getElementById('club').value === "yes"){
vehend = vehend + 41;
addveh = addveh + 41;
if (document.getElementById('inception').value === "no"){
if ( vehend < 60 || addveh < 60){
if ( vehend < 60 && addveh < 60){
vehend = 60;
addveh = 60;
}else if(vehend < 60 ){
vehend = 60;
}else {
addveh = 60;
}
}else{
}
}else{
if ( vehend < 76 || addveh < 76){
if ( vehend < 76 && addveh < 76){
vehend = 76;
addveh = 76;
}else if(vehend < 76 ){
vehend = 76;
}else {
addveh = 76;
}
}else{
}
}
}else {
vehend = vehend + 67;
addveh = addveh + 67;
if (document.getElementById('inception').value === "no"){
if ( vehend < 60 || addveh < 60){
if ( vehend < 60 && addveh < 60){
vehend = 60;
addveh = 60;
}else if(vehend < 60 ){
vehend = 60;
}else {
addveh = 60;
}
}else{
}
}else{
if ( vehend < 102 || addveh < 102){
if ( vehend < 102 && addveh < 102){
vehend = 102;
addveh = 102;
}else if(vehend < 102 ){
vehend = 102;
}else {
addveh = 102;
}
}else{
}
}
if ( document.getElementById('garage').value === "no"){
if ( document.getElementById('area').value == 1){
}else if ( document.getElementById('area').value == 2){
var Decision = "Please refer";
}else if ( document.getElementById('area').value == 3){
var Decision = '<span style="color:red">Decline car must be garaged</span>';
}else{
var Decision = '<span style="color:red">Decline car must be garaged</span>';
}
}
if ( document.getElementById('lience').value == 1){
var Decision = '<span style="color:red">Decline Driver must have licence more than 1 year</span>';
}else if ( document.getElementById('lience').value == 2){
var addloading = addloading + '15% loading for 1-2 years driving <br/>';
var year1 = vehend / 100 * 15;
vehend = vehend + year1;
var year2 = addveh / 100 * 15;
addveh = addveh + year2;
}
if (inputload != ""){
var addloading = addloading + " " + inputload + '% for user input) <br/>';
var conload = vehend / 100 * inputload;
vehend = vehend + conload;
var conload2 = addveh / 100 * inputload;
addveh = addveh + conload2;
}else {
var addloading = addloading + ")";
}
if ( document.getElementById('business').value === "yes"){
var addloading = addloading + " " + '30% business use <br/>';
var businload = veh / 100 * 30;
var businload2 = addveh / 100 * 30;
vehend = vehend + businload;
addveh = addveh + businload2;
}
vehandipt = (vehend / 100 * 6) + vehend;
addandipt = (addveh / 100 * 6) + addveh;
document.getElementById('result').innerHTML = vehend + " " + Decision + " " + addloading + " " + vehandipt;
}