Tenaciousmug Posted October 18, 2012 Share Posted October 18, 2012 Okay I know this error is common. And it's mainly always a syntax problem, but I can not for the life of me figure out what is wrong with my code. I tried putting the getUrlParameter function inside the document.ready() function.. I also tried both of them outside of it.. every possibility you can imagine, I tried. So it has to be something else. I've been staring at it for the past hour or so... Maybe a second pair of eyes can help me out here. <script type="text/javascript"> function getURLParameter(name) { /*var parameter = decodeURI( (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] ); if (parameter == null) { return null; } else { return parameter; }*/ name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) { return null; } else { return results[1]; } } $(document).ready(function() { var lng = getUrlParameter('long'); var lat = getUrlParameter('lat'); if(lng==null && lat==null) { var mapOptions = { zoom: 8, center: new google.maps.LatLng(-34.397, 150.644), mapTypeId: google.maps.MapTypeId.ROADMAP }; } else { var mapOptions = { zoom: 8, center: new google.maps.LatLng(lat, lng), mapTypeId: google.maps.MapTypeId.ROADMAP }; } var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); }); </script> Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/269646-function-not-defined/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 18, 2012 Share Posted October 18, 2012 Your need to check your capitalization of the function name. Quote Link to comment https://forums.phpfreaks.com/topic/269646-function-not-defined/#findComment-1386136 Share on other sites More sharing options...
Tenaciousmug Posted October 18, 2012 Author Share Posted October 18, 2012 Wow you're a genius PFMaBiSmAd!!! I never knew that was an issue in Javascript. Now I know all lowercase with underscores for function names. Thank you so much!!!! Quote Link to comment https://forums.phpfreaks.com/topic/269646-function-not-defined/#findComment-1386140 Share on other sites More sharing options...
Adam Posted October 20, 2012 Share Posted October 20, 2012 Lower-case with underscores? General convention with JS is to use camel case, like you're doing. Quote Link to comment https://forums.phpfreaks.com/topic/269646-function-not-defined/#findComment-1386629 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.