Jump to content

HTML elements inside a JS Loop doesnt work


needs_upgrade

Recommended Posts

Hello guys. I have a very large javascript file used for validating inputs. I want to make it shorter but it's not working. I'll be showing the new JS function code and the old one. Pls feel free to criticize or suggest something better. More power to you guys! thanks.

 

 

New JS code:

function valAddCReturn() {
   if (checkAddCReturn()) {
      document.AddCReturn.submit();
   }
}
function checkAddCReturn() {
if (document.AddCReturn.rc_id.value == "") {
	if (document.AddCReturn.whouse_id.selectedIndex == 0) {
		alert("Please select from the list of warehouses!");
		document.AddCReturn.whouse_id.focus();
		document.AddCReturn.whouse_id.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.ref_num.value.length == 0) {
		alert("Please enter the reference number!");
		document.AddCReturn.ref_num.focus();
		document.AddCReturn.ref_num.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.customer_id.selectedIndex == 0) {
		alert("Please select from the list of customers!");
		document.AddCReturn.customer_id.focus();
		document.AddCReturn.customer_id.style.backgroundColor = "#FFFF00";
		return false;
	}
}
if ((document.AddCReturn.product_id1.value.length == 0) && 
	(document.AddCReturn.product_id2.value.length == 0) && 
	(document.AddCReturn.product_id3.value.length == 0) && 
	(document.AddCReturn.product_id4.value.length == 0) && 
	(document.AddCReturn.product_id5.value.length == 0) && 
	(document.AddCReturn.product_id6.value.length == 0) && 
	(document.AddCReturn.product_id7.value.length == 0) && 
	(document.AddCReturn.product_id8.value.length == 0) && 
	(document.AddCReturn.product_id9.value.length == 0) && 
	(document.AddCReturn.product_id10.value.length == 0) &&
	(document.AddCReturn.product_id11.value.length == 0) && 
	(document.AddCReturn.product_id12.value.length == 0) && 
	(document.AddCReturn.product_id13.value.length == 0) && 
	(document.AddCReturn.product_id14.value.length == 0) && 
	(document.AddCReturn.product_id15.value.length == 0) && 
	(document.AddCReturn.product_id16.value.length == 0) && 
	(document.AddCReturn.product_id17.value.length == 0) && 
	(document.AddCReturn.product_id18.value.length == 0) && 
	(document.AddCReturn.product_id19.value.length == 0) && 
	(document.AddCReturn.product_id20.value.length == 0)) {
	alert("Product Return should contain at least one (1) product!");
	return false;
} else {
	for (var i = 1; i < 21; i++) {
		if (document.AddCReturn.product_id[i].value.length != 0 && document.AddCReturn.quantity[i].value == 0 && document.AddCReturn.unit_price[i].value == 0) {
			alert("All entries for Item #" + i + "should have values");
			document.AddCReturn.product_id[i].style.backgroundColor = "#FFFF00";
			return false;
		}
	}
}
for (var x = 1; x < 20; x++) {
	if (document.AddCReturn.product_id[x].value.length != 0) {
		for (var y = x+1; y < 21; y++) {
			if (document.AddCReturn.product_id[x].value == document.AddCReturn.product_id[y].value) {
				alert("Entries for products " + x + "and" + y + "are the same!");
				document.AddCReturn.product_id[x].style.backgroundColor = "#FFFF00";
				document.AddCReturn.product_id[y].style.backgroundColor = "#FFFF00";
				return false;
			}
		}
	}
}
return true; 
}

 

 

Old JS code but i have to cut it short because of length limit:

function valAddCReturn() {
   if (checkAddCReturn()) {
      document.AddCReturn.submit();
   }
}
function checkAddCReturn() {
if (document.AddCReturn.rc_id.value == "") {
	if (document.AddCReturn.whouse_id.selectedIndex == 0) {
		alert("Please select from the list of warehouses!");
		document.AddCReturn.whouse_id.focus();
		document.AddCReturn.whouse_id.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.ref_num.value.length == 0) {
		alert("Please enter the reference number!");
		document.AddCReturn.ref_num.focus();
		document.AddCReturn.ref_num.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.customer_id.selectedIndex == 0) {
		alert("Please select from the list of customers!");
		document.AddCReturn.customer_id.focus();
		document.AddCReturn.customer_id.style.backgroundColor = "#FFFF00";
		return false;
	}
}
if ((document.AddCReturn.product_id1.value.length == 0) && 
	(document.AddCReturn.product_id2.value.length == 0) && 
	(document.AddCReturn.product_id3.value.length == 0) && 
	(document.AddCReturn.product_id4.value.length == 0) && 
	(document.AddCReturn.product_id5.value.length == 0) && 
	(document.AddCReturn.product_id6.value.length == 0) && 
	(document.AddCReturn.product_id7.value.length == 0) && 
	(document.AddCReturn.product_id8.value.length == 0) && 
	(document.AddCReturn.product_id9.value.length == 0) && 
	(document.AddCReturn.product_id10.value.length == 0) &&
	(document.AddCReturn.product_id11.value.length == 0) && 
	(document.AddCReturn.product_id12.value.length == 0) && 
	(document.AddCReturn.product_id13.value.length == 0) && 
	(document.AddCReturn.product_id14.value.length == 0) && 
	(document.AddCReturn.product_id15.value.length == 0) && 
	(document.AddCReturn.product_id16.value.length == 0) && 
	(document.AddCReturn.product_id17.value.length == 0) && 
	(document.AddCReturn.product_id18.value.length == 0) && 
	(document.AddCReturn.product_id19.value.length == 0) && 
	(document.AddCReturn.product_id20.value.length == 0)) {
	alert("Product Return should contain at least one (1) product!");
	return false;
} else {
	if (document.AddCReturn.product_id1.value.length != 0 && document.AddCReturn.quantity1.value == 0 && document.AddCReturn.unit_price1.value == 0) {
		alert("All entries for Item #1 should have values");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value.length != 0 && document.AddCReturn.quantity2.value == 0 && document.AddCReturn.unit_price2.value == 0) {
		alert("All entries for Item #2 should have values");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value.length != 0 && document.AddCReturn.quantity3.value == 0 && document.AddCReturn.unit_price3.value == 0) {
		alert("All entries for Item #3 should have values");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value.length != 0 && document.AddCReturn.quantity4.value == 0 && document.AddCReturn.unit_price4.value == 0) {
		alert("All entries for Item #4 should have values");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value.length != 0 && document.AddCReturn.quantity5.value == 0 && document.AddCReturn.unit_price5.value == 0) {
		alert("All entries for Item #5 should have values");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id6.value.length != 0 && document.AddCReturn.quantity6.value == 0 && document.AddCReturn.unit_price6.value == 0) {
		alert("All entries for Item #6 should have values");
		document.AddCReturn.product_id6.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id7.value.length != 0 && document.AddCReturn.quantity7.value == 0 && document.AddCReturn.unit_price7.value == 0) {
		alert("All entries for Item #7 should have values");
		document.AddCReturn.product_id7.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id8.value.length != 0 && document.AddCReturn.quantity8.value == 0 && document.AddCReturn.unit_price8.value == 0) {
		alert("All entries for Item #8 should have values");
		document.AddCReturn.product_id8.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id9.value.length != 0 && document.AddCReturn.quantity9.value == 0 && document.AddCReturn.unit_price9.value == 0) {
		alert("All entries for Item #9 should have values");
		document.AddCReturn.product_id9.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id10.value.length != 0 && document.AddCReturn.quantity10.value == 0 && document.AddCReturn.unit_price10.value == 0) {
		alert("All entries for Item #10 should have values");
		document.AddCReturn.product_id10.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id11.value.length != 0 && document.AddCReturn.quantity11.value == 0 && document.AddCReturn.unit_price11.value == 0) {
		alert("All entries for Item #11 should have values");
		document.AddCReturn.product_id11.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id12.value.length != 0 && document.AddCReturn.quantity12.value == 0 && document.AddCReturn.unit_price12.value == 0) {
		alert("All entries for Item #12 should have values");
		document.AddCReturn.product_id12.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id13.value.length != 0 && document.AddCReturn.quantity13.value == 0 && document.AddCReturn.unit_price13.value == 0) {
		alert("All entries for Item #13 should have values");
		document.AddCReturn.product_id13.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id14.value.length != 0 && document.AddCReturn.quantity14.value == 0 && document.AddCReturn.unit_price14.value == 0) {
		alert("All entries for Item #14 should have values");
		document.AddCReturn.product_id14.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id15.value.length != 0 && document.AddCReturn.quantity15.value == 0 && document.AddCReturn.unit_price15.value == 0) {
		alert("All entries for Item #15 should have values");
		document.AddCReturn.product_id15.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id16.value.length != 0 && document.AddCReturn.quantity16.value == 0 && document.AddCReturn.unit_price16.value == 0) {
		alert("All entries for Item #16 should have values");
		document.AddCReturn.product_id16.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id17.value.length != 0 && document.AddCReturn.quantity17.value == 0 && document.AddCReturn.unit_price17.value == 0) {
		alert("All entries for Item #17 should have values");
		document.AddCReturn.product_id17.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id18.value.length != 0 && document.AddCReturn.quantity18.value == 0 && document.AddCReturn.unit_price18.value == 0) {
		alert("All entries for Item #18 should have values");
		document.AddCReturn.product_id18.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id19.value.length != 0 && document.AddCReturn.quantity19.value == 0 && document.AddCReturn.unit_price19.value == 0) {
		alert("All entries for Item #19 should have values");
		document.AddCReturn.product_id19.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id20.value.length != 0 && document.AddCReturn.quantity20.value == 0 && document.AddCReturn.unit_price20.value == 0) {
		alert("All entries for Item #20 should have values");
		document.AddCReturn.product_id20.style.backgroundColor = "#FFFF00";
		return false;
	}
}
if (document.AddCReturn.product_id1.value.length != 0) {
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id2.value) {
		alert("Entries for products 1 and 2 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id3.value) {
		alert("Entries for products 1 and 3 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id4.value) {
		alert("Entries for products 1 and 4 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id5.value) {
		alert("Entries for products 1 and 5 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id6.value) {
		alert("Entries for products 1 and 6 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id6.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id7.value) {
		alert("Entries for products 1 and 7 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id7.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id8.value) {
		alert("Entries for products 1 and 8 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id8.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id9.value) {
		alert("Entries for products 1 and 9 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id9.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id10.value) {
		alert("Entries for products 1 and 10 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id10.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id11.value) {
		alert("Entries for products 1 and 11 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id11.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id12.value) {
		alert("Entries for products 1 and 12 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id12.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id13.value) {
		alert("Entries for products 1 and 13 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id13.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id14.value) {
		alert("Entries for products 1 and 14 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id14.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id15.value) {
		alert("Entries for products 1 and 15 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id15.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id16.value) {
		alert("Entries for products 1 and 16 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id16.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id17.value) {
		alert("Entries for products 1 and 17 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id17.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id18.value) {
		alert("Entries for products 1 and 18 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id18.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id19.value) {
		alert("Entries for products 1 and 19 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id19.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id1.value == document.AddCReturn.product_id20.value) {
		alert("Entries for products 1 and 20 are the same!");
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id20.style.backgroundColor = "#FFFF00";
		return false;
	}
}
if (document.AddCReturn.product_id2.value.length != 0) {
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id3.value) {
		alert("Entries for products 2 and 3 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id4.value) {
		alert("Entries for products 2 and 4 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id5.value) {
		alert("Entries for products 2 and 5 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id6.value) {
		alert("Entries for products 2 and 6 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id6.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id7.value) {
		alert("Entries for products 2 and 7 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id7.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id8.value) {
		alert("Entries for products 2 and 8 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id8.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id9.value) {
		alert("Entries for products 2 and 9 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id9.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id10.value) {
		alert("Entries for products 2 and 10 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id10.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id11.value) {
		alert("Entries for products 2 and 11 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id11.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id12.value) {
		alert("Entries for products 2 and 12 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id12.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id13.value) {
		alert("Entries for products 2 and 13 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id13.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id14.value) {
		alert("Entries for products 2 and 14 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id14.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id15.value) {
		alert("Entries for products 2 and 15 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id15.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id16.value) {
		alert("Entries for products 2 and 16 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id16.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id17.value) {
		alert("Entries for products 2 and 17 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id17.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id18.value) {
		alert("Entries for products 2 and 18 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id18.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id19.value) {
		alert("Entries for products 2 and 19 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id19.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id2.value == document.AddCReturn.product_id20.value) {
		alert("Entries for products 2 and 20 are the same!");
		document.AddCReturn.product_id2.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id20.style.backgroundColor = "#FFFF00";
		return false;
	}
}
if (document.AddCReturn.product_id3.value.length != 0) {
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id4.value) {
		alert("Entries for products 3 and 4 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id5.value) {
		alert("Entries for products 3 and 5 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id6.value) {
		alert("Entries for products 3 and 6 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id6.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id7.value) {
		alert("Entries for products 3 and 7 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id7.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id8.value) {
		alert("Entries for products 3 and 8 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id8.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id9.value) {
		alert("Entries for products 3 and 9 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id9.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id10.value) {
		alert("Entries for products 3 and 10 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id10.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id11.value) {
		alert("Entries for products 3 and 11 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id12.value) {
		alert("Entries for products 3 and 12 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id13.value) {
		alert("Entries for products 3 and 13 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id14.value) {
		alert("Entries for products 3 and 14 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id15.value) {
		alert("Entries for products 3 and 15 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id16.value) {
		alert("Entries for products 3 and 16 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id17.value) {
		alert("Entries for products 3 and 17 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id18.value) {
		alert("Entries for products 3 and 18 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id19.value) {
		alert("Entries for products 3 and 19 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id3.value == document.AddCReturn.product_id20.value) {
		alert("Entries for products 3 and 20 are the same!");
		document.AddCReturn.product_id3.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id1.style.backgroundColor = "#FFFF00";
		return false;
	}
}
if (document.AddCReturn.product_id4.value.length != 0) {
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id5.value) {
		alert("Entries for products 4 and 5 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id6.value) {
		alert("Entries for products 4 and 6 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id6.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id7.value) {
		alert("Entries for products 4 and 7 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id7.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id8.value) {
		alert("Entries for products 4 and 8 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id8.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id9.value) {
		alert("Entries for products 4 and 9 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id9.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id10.value) {
		alert("Entries for products 4 and 10 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id10.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id11.value) {
		alert("Entries for products 4 and 11 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id11.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id12.value) {
		alert("Entries for products 4 and 12 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id12.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id13.value) {
		alert("Entries for products 4 and 13 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id13.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id14.value) {
		alert("Entries for products 4 and 14 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id14.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id15.value) {
		alert("Entries for products 4 and 15 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id15.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id16.value) {
		alert("Entries for products 4 and 16 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id16.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id17.value) {
		alert("Entries for products 4 and 17 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id17.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id18.value) {
		alert("Entries for products 4 and 18 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id18.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id19.value) {
		alert("Entries for products 4 and 19 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id19.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id4.value == document.AddCReturn.product_id20.value) {
		alert("Entries for products 4 and 20 are the same!");
		document.AddCReturn.product_id4.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id20.style.backgroundColor = "#FFFF00";
		return false;
	}
}
if (document.AddCReturn.product_id5.value.length != 0) {
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id6.value) {
		alert("Entries for products 5 and 6 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id6.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id7.value) {
		alert("Entries for products 5 and 7 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id7.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id8.value) {
		alert("Entries for products 5 and 8 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id8.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id9.value) {
		alert("Entries for products 5 and 9 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id9.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id10.value) {
		alert("Entries for products 5 and 10 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id10.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id11.value) {
		alert("Entries for products 5 and 11 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id11.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id12.value) {
		alert("Entries for products 5 and 12 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id12.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id13.value) {
		alert("Entries for products 5 and 13 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id13.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id14.value) {
		alert("Entries for products 5 and 14 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id14.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id15.value) {
		alert("Entries for products 5 and 15 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id15.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id16.value) {
		alert("Entries for products 5 and 16 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id16.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id17.value) {
		alert("Entries for products 5 and 17 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id17.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id18.value) {
		alert("Entries for products 5 and 18 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id18.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id19.value) {
		alert("Entries for products 5 and 19 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id19.style.backgroundColor = "#FFFF00";
		return false;
	}
	if (document.AddCReturn.product_id5.value == document.AddCReturn.product_id20.value) {
		alert("Entries for products 5 and 20 are the same!");
		document.AddCReturn.product_id5.style.backgroundColor = "#FFFF00";
		document.AddCReturn.product_id20.style.backgroundColor = "#FFFF00";
		return false;
	}
}
return true;
}

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.