Welcome Guest, Not a member yet? Register   Sign In
javascript files with php code
#5

So basically, you do something like this:

Code:
<head>
<script>
      var url = "<?php echo base_url() ?>admin/products";
      // etc etc
</script>
</head>

<script src="path/to/some/file.js"></script>

// and then in your script in file.js you can access the url
url : url,
etc etc

Am I right ?

but what you do in cases like this, where you need to loop to set dynamically some js data ? See this example:
PHP Code:
'columns': [
       <?
php foreach($array_items as $item): ?>
        { 'data': '<?php echo $item?>' },
        <?php endforeach; ?>
], 
Reply


Messages In This Thread
javascript files with php code - by Lykos22 - 10-02-2015, 09:02 AM
RE: javascript files with php code - by freddy - 10-02-2015, 08:14 PM
RE: javascript files with php code - by JayAdra - 10-02-2015, 08:24 PM
RE: javascript files with php code - by Lykos22 - 10-15-2015, 08:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB