I have a JS function as below
// A simple array where we keep track of things that are filed.
filed = [];
function fileIt(thing) {
// Dynamically call the file method of whatever 'thing' was passed in.
thing.file();
// Mark as filed
filed.push(thing);
}
Now, function fileIt(thing) is working well when called as below
fileIt(AuditForm);
Whereas, its giving error at line thing.file(); when i am trying to pass a variable like below
var formID = obj.id;
fileIt(formID);
Variable formID has same value and i.e. "AuditForm" what's wrong here. Kindly suggest.
obj.idis a string value, whereas when you hard codeAuditFormit's a reference to the variable which holds, presumably, an object which has afile()method. There are solutions to this problem, but without a clear example of your code we can't really guide you any further.formIDis probably a Number or a string. Numeric/String types have no.fileprototype.formIDsimilar toAuditForm, instead of hardcoding i need to pass it as variable as multiple options may be available