hello can anyone tel me that either we can insert php code in javascript code for dynamic menu submenu creation . plz advice me ; thx
Save the javascript file with a .php extension, and add this line at the top of it. header('Content-Type: text/javascript'); PHP: Then include the file like it was a normal javascript file. <script type="text/javascript" src="file.php"></script> Code (javascript):
also you can insert special .htaccess instructions to your folder with js files there you will specify that apache need first to parse some php
Are you thinking like this: <script><? echo $tring; ?> </script> If so maybe think like this <? $javacode = "<script>$tring</script>"; ?>
The cleanest way would be to add this code to the .htaccess file containing your javascript file. This will tell apache to parse any file ending with .js as php before outputting. <Files *.js> AddHandler application/x-httpd-php .js </Files> Code (markup):