Click to See Complete Forum and Search --> : syntax error


sisi
01-19-2004, 10:45 AM
Hello,

I am trying to write the following html, using javascript:

<SCRIPT language=JavaScript src="test.js" type=text/javascript></SCRIPT>

The whole point being that i want to choose randomly between 4 .js files i have. This is the javascript I wrote:

<SCRIPT type="text/javascript" language="JavaScript">
<!--
document.write(<SCRIPT language="JavaScript" src="src_Menu[cycle]" type="text/javascript"></SCRIPT>);

//-->

</SCRIPT>

When i try to view my page a web browser, i get the following error:

syntax error

If i do document.write of src_Menu[cycle], i get the path to the .js file.

What am i doing wrong?

fredmv
01-19-2004, 11:03 AM
Welcome to the forums.document.write('<script type="text/javascript" src="' + src_Menu[cycle] + '"></script>');

sisi
01-19-2004, 11:16 AM
when i try this, i get this prtion of the script displayed on the page:

') //--> test1.js

test1.js is the path for the .js file.

Nayias
01-19-2004, 12:11 PM
maybe its an error in 1 of the files?