Welcome Guest, Not a member yet? Register   Sign In
Passing variables to my_javascript.js.php
#1

[eluser]See64[/eluser]
I want to dynamically change the external javascript file that's been included with each pageload, to get something similar as this:

Code:
alert("<?=$variable_set_in_ci?>");

All variables set with CI are unset when I try this. How can I fix this?

The other solution would be generating the javascript and echo'ing it at the bottom of the body... seems like an ugly fix.
#2

[eluser]Derek Allard[/eluser]
This is the nature of client and server side environments. What I do is create a script section in the head of each document that contains the relevent js variables and then reference those variables in external js files. Download BambooInvoice if you want to see it in action.




Theme © iAndrew 2016 - Forum software by © MyBB