HTML:
<script src="stock.js" type="text/javascript">document.write(quantity_in_stock_S);</script>
Javascript (stock.js):
var quantity_in_stock_S = 10
I am wanting the HTML to print out the number 10 but it doesn't seem to be working. Any ideas?
stock.js
var quantity_in_stock_S = 10; document.write(quantity_in_stock_S);
html
<script src="stock.js" type="text/javascript"></script> </head> <body>
When the src attribute is present on a script tag, it ignores the code between the opening and closing tag.
document.write isn't a JavaScript function. It's a DOM method.
Anyways... what the other posters said is correct. Put all your code in that script.js file, or use a separate script tag.