view raw
wOlVeRiNe wOlVeRiNe - 6 months ago 31
HTML Question

Accesing variables declared in JAVASCRIPT in a different HTML FILE

I have two files screen.html and db_fun.js.
I have declared a variable at just the beginning as follows:


var name = "abc";

now i tried to access this variable in the screen.html file as follows


<form name = "screen" action = "db_fun.js">
<p> <script>document.write(name);</script> </p>
<script src="db_fun.js" type="text/javascript" />

it doesn't print nethn. Y so?


add this to the head

<script type="text/javascript" src="db_fun.js"></script>