![]() |
javascript function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: javascript function (/showthread.php?tid=28102) |
javascript function - El Forum - 03-02-2010 [eluser]husni[/eluser] this is my js file name example.js Code: function hello() this is my controller Code: <?php this is my view file Code: <html> i want to call the hello() function in my view file..anyone can help me? javascript function - El Forum - 03-02-2010 [eluser]farinspace[/eluser] then call it ... either call the function in example.js (which would call it on every page that uses the example.js file) or simply include an inline script and call the function for the specific view ... Code: <html> javascript function - El Forum - 03-02-2010 [eluser]husni[/eluser] [quote author="farinspace" date="1267532949"]then call it ... either call the function in example.js (which would call it on every page that uses the example.js file) or simply include an inline script and call the function for the specific view ... Code: <html> didn't works.. javascript function - El Forum - 03-02-2010 [eluser]maria clara[/eluser] You can place your images etc within separate folders too if you wish. The folders must be in the same directory as your index.php file though. You should not be putting any static content anywhere in your application folder. I tend to setup my CI directory structure like so Quote:My CodeIgniter App When loading say .js within my views for example I'd use Code: <XXscript type="text/javascript" src="<?=echo base_url()?>lib/js/js file"> </XXscript> then in ur controller: Code: function js() javascript function - El Forum - 03-02-2010 [eluser]farinspace[/eluser] Make sure that the browser is loading the "example.js" file properly ... |