Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  10] [ 1]  / answers: 1 / hits: 59293  / 10 Years ago, fri, october 3, 2014, 12:00:00

Pardon me for not being clear, but have thia script that is really long. When I have it live, I get this error in Chrome's Console.




Uncaught TypeError: Cannot read property 'substr' of undefined




here is the snippet of code where it is reading from.



var formIddd = $('select[class~=FormField]').get(numSelec).name.substr($('select[class~=FormField]').get(numSelec).name.length-3,2);


I looked up substr on google and it appears to be a known property. I also found the classes. I have played with the lengths, but still getting stuck. It used to work until BigCommerce did an update.



Any advice much appreciated, cheers.


More From » jquery

 Answers
10

You are not populating your array. The if check is false.



enter



so basically you are doing this



var arrayOfSelectOfCountry = [];
var numSelec = arrayOfSelectOfCountry[-1]; //undefined


which results in the error above.


[#69253] Wednesday, October 1, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cruzs

Total Points: 710
Total Questions: 113
Total Answers: 100

Location: Nepal
Member since Sat, Jul 18, 2020
4 Years ago
cruzs questions
Thu, Nov 26, 20, 00:00, 4 Years ago
Wed, Oct 28, 20, 00:00, 4 Years ago
Wed, Aug 19, 20, 00:00, 4 Years ago
Sun, Aug 2, 20, 00:00, 4 Years ago
;