I need to embed a player by the following code:
<script type="text/javascript" src=***the url***></script>
A part in the url is the ID which is retrieved from mySQL database. I know that the string concatenation can't be directly handled in the src, so I add the function in the beginning:
<head>
<script>
function call(url)
{
var script = document.createElement('script');
script.type="text/javascript";
script.src = url;
document.body.appendChild(script);
}
</script>
</head>
In the body,
<body>
<?php ***...to retrieve ID***?>
<script type="text/javascript">
var videoid = "<?php echo $id; ?>"; //Transfer ID to javascript
var url="http://......"+videoid; //Url string finished
call(url); //Function call
</script>
Now the script is appended, but I can't see the player. Why?