I'm guessing this is a stupid question but I'm having a lot of trouble with this simple function:
--Sits in .js file--
function GetAssets() {
alert("Hello World!");
document.getElementById("asset_summary").innerHTML = "Test";
}
--sits in html.erb file--
<script type="text/javascript" src="jslogic/overview_summary.js"></script>
<script>GetAssets();</script>
I know the function call works b/c I can comment out the document.getElementByID line and then get an alert. I know the document.getElementByID works because I can copy/paste it into a script tag and it runs. So something must change in the syntax when you move this call to an external file? I'm sure this is easy but I can't find the right reference to fix it. Thanks in advance!
Clarifying the buried question: this function doesn't run properly and I'm assuming it's because of the document.getElementByID attribute on line 3 - if it is, could someone explain how I need to change this? If it's not, can someone explain why this works within the html script tags but not as a separate function?