bravo14 Posted January 14, 2014 Share Posted January 14, 2014 I have a .js file that is referenced in the page, but when I try and run the functions from it the debugger says that the function is undefined. the HTML to load the js file is <script language="JavaScript" type="text/javascript" src="http://www.starkeracing.co.uk/fullthrottle/library/club.js"></script> the call to the function in the HTML <a href="javascript:modifyClub(5);">Modify</a> and the JavaScript file is function modifyClub(clubId) { function code here } I don't understand why it is saying the function is undefined. Quote Link to comment https://forums.phpfreaks.com/topic/285354-functioned-undefined/ Share on other sites More sharing options...
jburridge Posted January 31, 2014 Share Posted January 31, 2014 It's saying function undefined because all you have inside the function is "function code here", In other words...Theirs no return value. Quote Link to comment https://forums.phpfreaks.com/topic/285354-functioned-undefined/#findComment-1467278 Share on other sites More sharing options...
jburridge Posted January 31, 2014 Share Posted January 31, 2014 my mistake didn't see the js file above. Same thing though, You are not returning any values. Try variable=window.location.href = 'index.php?view=modify&clubId=' + clubId; return variable; Quote Link to comment https://forums.phpfreaks.com/topic/285354-functioned-undefined/#findComment-1467281 Share on other sites More sharing options...
jburridge Posted January 31, 2014 Share Posted January 31, 2014 REALLY wish I could edit a damn post. variable='index.php?view=modify&clubId=' + clubId; return variable; Quote Link to comment https://forums.phpfreaks.com/topic/285354-functioned-undefined/#findComment-1467282 Share on other sites More sharing options...
kicken Posted January 31, 2014 Share Posted January 31, 2014 Your javascript file has an error in it, right here: with (window.document.frmAddProduct) { } else if (isEmpty(txtName, 'Enter Product name')) { return; } else { submit(); } } Because of that, the entire file cannot be loaded and none of it's functions will be defined. You need to fix that error then it will define the function. What you are doing is a poor practice also. There is no need to involve Javascript here as all you are doing is linking to another page. Just simply do: <a href="index.php?view=modify&club=5">Modify</a> Quote Link to comment https://forums.phpfreaks.com/topic/285354-functioned-undefined/#findComment-1467285 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.