Hey everyone,

I have been receiving an error that states that one of my variables ("$fileAmount") is undefined. I was hoping you guys might see something in my code where I am making a mistake. Please note that this is not the entire code, but where the error is occurring. "Browser" is a file browser used for uploading files. It errors on the third line of the function saying that $fileAmount is undefined.

var fileAmount=0;
function checkExtension()
	{
		if(document.getElementById("browser" + $fileAmount).value != '')
		{
			var fileName1 = document.getElementById("browser" + $fileAmount).value;
			fileName1 = fileName1.substring(fileName1.lastIndexOf('\\') + 1);
			var fileExt = fileName1.substring(fileName1.lastIndexOf('.') + 1);
			if ((fileExt == 'txt'))
			{
				$fileAmount++;
				return;
			}
			else
			{
				alert("Use valid file type");
				document.getElementById("browser" + $fileAmount).focus();
				return false;
			}
		}
	}

Thank you all for your help!

Recommended Answers

All 2 Replies

Nevermind! Answered my own question...... Funny how that works.

Thanks Daniweb!

Winky, can you mark Solved please.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.