I'm sure I've got membership on some JS forum or another, but can't be bothered to get a new password. I know some of us are pretty good with JS.
Why did I have to add the var "tmp" in the function below?
function check_duplicate_company_name() { // warn operator if name already entered
var newCompanyName, companyListItems, i, tmp;
newCompanyName = document.forms[0].elements[0].value;
companyListItems = document.getElementsByClassName( 'company_name' );
for ( i = 0; i <= companyListItems.length; ++i ) {
tmp = companyListItems[i];
if ( tmp.value == newCompanyName ) {
alert( "Company Already Exists." );
return false;
}
}
submit_the_form();
} //EOF
I tried "if (companyListItems.value == newCompanyName)" and got undefined errors. Why is that? Is there some concept I'm not understanding here?