We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,376 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

call a js variable from php file

in my home.php file i hv defined one path as javascript variable like below:

<?php $path= "http://localhost/tiffany/" ?>

 <script type="text/javascript" src="<?php echo $path; ?>js/manuals.js"></script>

 <script type="text/javascript" > 
  var  templateUrl  = '<?php echo $path; ?>'; 
  </script>

& in my 'manuals.js' file i have included someother js files adding with that variable:

include(templateUrl+'js/mathUtils.js');
include(templateUrl+'js/superfish.js');
include(templateUrl+'js/switcher.js');
and so on....

no err for 'manuals.js' file but get error for all inlcuded .js files:
ReferenceError: templateUrl is not defined

please hlp me whr to change or edit ..

2
Contributors
2
Replies
56 Minutes
Discussion Span
6 Months Ago
Last Updated
3
Views
Question
Answered
doha786
Light Poster
44 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Do this ...

<?php $path= "http://localhost/tiffany/" ?>
<script type="text/javascript" >
var templateUrl = '<?php echo $path; ?>';
</script>
<script type="text/javascript" src="<?php echo $path; ?>js/manuals.js"></script>
Robert1995
Junior Poster in Training
58 posts since Feb 2010
Reputation Points: 32
Solved Threads: 7
Skill Endorsements: 0

great ... thanks man

doha786
Light Poster
44 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 6 Months Ago by Robert1995

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0586 seconds using 2.66MB