I have a search page which takes time to load results on submit. So i decided to show a loading.gif to keep the user entertained while it loads. below is the javascript function, the div element on jsp and the call to the javascript function.
JS
function goodbye(){
console.log();
var pb = document.getElementById("loading");
pb.innerHTML = '<img src= "images/loadingAnimation.gif" />';
pb.style.display = 'block';
return true;
}
div
<div id="loading" style="position:absolute; width:100%; text-align:20%; top:100px; height: auto; left: 500px;"></div>
Call to JS
<td><html:submit property="method" value="Submit"
onclick="return goodbye();" styleClass="btn2" /></td>
i even get "LOG:" on the console. and all java script is on the same page between script tags and not in a seperate .js file
Edit: I have the div tag between the body tag and form tag.