FadelMS
FadelMS

Reputation: 2037

inserting JS variables into html tag

I'm trying to insert a JS variable in html tags and I don't know what I'm doing wrong. The movie does not load. Here is my code:

var moviePath = "images/main.swf";    
<script>document.write('<PARAM name="movie" value="' + moviePath + '">')</script> 

Upvotes: 0

Views: 9117

Answers (1)

Jules
Jules

Reputation: 7233

Your var seems to be outside of your script..?

Try:

<script type="text/javascript">
    var moviePath = "images/main.swf";
    document.write('<param name="movie" value="' + moviePath + '">');
</script>

Upvotes: 6

Related Questions