I have a video player which is javascript. I have stuck it inside a php variable and then have attempted to echo it out. It works perfectly the first time i echo the video. But the second time I echo it the Javascript does not execute. Any ideas on why that is are helpful thank you
$div = "<div id='mediaplayer'>JW Player goes here</div>";
$video = "$div <script type='text/javascript' src='jwplayer/jwplayer.js'></script>
<script type='text/javascript'>
jwplayer('mediaplayer').setup({
flashplayer: 'jwplayer/player.swf',
file: '$videolocation',
image: 'jwplayer/preview.jpg',
height: 300,
width: 300
});
</script>";
echo $video;
echo $video;
Your HTML is invalid. Use a validator.
The values of
idattributes must be unique within a page. You are reusing yours.The second script is probably operating on the first div (since it is the first one with the given id).