I have a problem with an js file in php. if i include it like this:
?> <script type="text/javascript" href="file.js"></script> <?php
the file isn’t included and i get an error that the function isn’t defined.
When i try it this way:
<script type="text/javascript"> document.write('<script type="text/javascript" src="datetimepicker_css.js"></script>'); </script>
the first tag in the document.write function closes <script type="text/javascript">
what is the correct way to do this?
thanks, sebastian
Advertisement
Answer
PHP is completely irrelevant for what you are doing. The generated HTML is what counts.
In your case, you are missing the src
attribute. Use
<script type="text/javascript" src="file.js"></script>