Hey Guys,
I am getting this error cannot call method substr of undefined when I try to get substring of a string.
Any solutions?
6 Answers
please show some code?
see this reference http://www.w3schools.com/jsref/jsref_substring.asp
Actually you are trying to call substr method on an undefined Strin variable.So Check out the value of that variable and then call substr method on that string variable.
Thanks
Either the variable is not string type or it is null.
As error message says, variable is "undefined".
if (stringVal) { stringVal.substr(...); }
what is the type and value of stringVal variable? Put alert before "if" condition and check it.
I think, pankaj and many, made right choice and answer your problem. put some code here to tell you why it is happening.
Your Answer
Think you can help? Login to answer this question!