I'm newer to Javascript, so sorry if I'm taking the wrong approach.
I am looking to identify an element on a page by Class Name, hide it, and replace it with the text "Loading..."
Here's what I have so far, which does successfully blank the page, however, my replacement message doesn't show.
<style>
.loading{
display: block;
}
</style>
<script>
if (checkRequiredFields(document.forms[0]) && document.InfoForm.FUDF9.value=="Y1")
{
var elems = document.getElementsByClassName("name");
for (i = 0; i < elems.length; i++) {
elems[i].style.display = "none";}
}
</script>
<div id = "loading"></div>
<script>
var Message1 = "Loading...";
if (checkRequiredFields(document.forms[0]) && document.InfoForm.FUDF9.value=='Y1'){
document.getElementByClassName("loading").innerHTML = Message1;}
</script>
It is a class name that a lot of elements on the page have, I've tried going to a narrower class name but that doesn't seem to hide the smaller individual elements. Any help would be appreciated.
EDIT: Okay, I reworked everything so it's all operating off an ID. Still confused about why it will blank the page but not show my message.
<style>
#loading{
display: block;
}
</style>
<div id = "loading"></div>
<script>
if (checkRequiredFields(document.forms[0]) && document.InfoForm.FUDF9.value=="Y1")
{
var elems = document.getElementsByClassName("name");
for (i = 0; i < elems.length; i++) {
elems[i].style.display = "none";}
}
var quickPledgeMessage1 = "Loading...";
if (checkRequiredFields(document.forms[0]) && document.InfoForm.FUDF9.value=='Y1'){
document.getElementById("loading").innerHTML = quickPledgeMessage1;}
</script>
document.getElementByClassName("loading")[0].innerHTML .... You will not see a refresh until the script finishes, you'll need to split it with setTimeout calls if you want to show something while processing occurs.