Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Uncaught ReferenceError: parameter is not defined

Tags:

javascript

I have some Javascript code:

function addRow(tableID, rowId) {
var table = document.getElementById(tableID);
var rowPosition = document.getElementById(rowID).rowIndex;
//etc.
}

But this throws a Javascript error

"Uncaught ReferenceError: rowID is not defined"

Though looking on Firebug, I can see that the functions receives a correct row identifier, but once the code reaches the second line inside the function the parameter rowID seems unknown.

Can anyone help?

like image 395
Timothée HENRY Avatar asked Jun 17 '11 13:06

Timothée HENRY


People also ask

How do I fix uncaught ReferenceError is not defined?

The $ is not defined ReferenceError usually arises when jQuery is not loaded and JavaScript is not recognizing the $ symbol. To solve this error, first, use jQuery CDN link inside the head section or download the jQuery file and use the jQuery file link inside the head section.

What is uncaught ReferenceError in JavaScript?

The Javascript ReferenceError occurs when referencing a variable that does not exist or has not yet been initialized in the current scope.

How do you handle uncaught ReferenceError?

Answer: Execute Code after jQuery Library has Loaded The most common reason behind the error "Uncaught ReferenceError: $ is not defined" is executing the jQuery code before the jQuery library file has loaded. Therefore make sure that you're executing the jQuery code only after jQuery library file has finished loading.


2 Answers

JavaScript is case-sensitive. You've used rowId as the argument name (small "d") while inside the function you have rowID (capital "D"). Change the argument to rowID to fix the issue.

like image 143
Ates Goral Avatar answered Sep 30 '22 08:09

Ates Goral


You're passing the parameter rowId, but referencing it rowID. Variable names are case sensitive, they both need to be the same.

like image 22
Jivings Avatar answered Sep 30 '22 08:09

Jivings