[Javascript] JavaScript syntax problem?

Rodney Myers rodney at aflyingstart.net
Sat Sep 14 06:13:33 CDT 2002


Dan,

As written the onClick will be

onclick=launchNow(myfile.html)

Note the absence of quote marks around the file name.
It is this that makes the interpreter react as if myfile.html was a
variable - and as such it is indeed undefined.

Try

document.write("<INPUT type='button' name='go_to'
value='Launch NOW' class='formButton' onclick
=launchNow('" + filename + "')>")

which will write
onclick=launchNow('myfile.html')

hth

Rodney


Dan wrote:

> Hi all,
>
> The script below, embedded in html page, is causing me
> some grief. While there is no syntax error message
> generated, it does say the value passed in by
> 'filename' is undefined. So, if the value of filename
> is "myfile.html", it complains about "myfile.html" not
> being defined.
>
> My guess is that I made a mistake in the syntax of the
> JavaScript below:
>
> document.write("<INPUT type='button' name='go_to'
> value='Launch NOW' class='formButton' onclick
> =launchNow(" + filename + ")>")
>
> Any ideas for correcting my error?
>
> Thanks.





More information about the Javascript mailing list