I was cleaning up my code so that it was more uniform. I placed a couple of javascript functions in the echo command. I was surprised to find that after I had done that, the functions no longer worked. There were no errors that I received, it was only when I went through the page that I noticed that my functions were no longer working. I'm still in my javascript infancy, so I'm not sure if this is a common error or not, but I couldn't find anything related to it.
I troubleshot it down to the third line by taking away all echoes and slowly adding in more until the problem resurfaced. So, I'm not sure what I'm doing wrong.
The purpose of the functions is to make a grey overlay over everything, then a small confirmation box pops-up asking if you want to proceed with the task.
echo '<script type="text/javascript">';
echo 'function showPopUp(el) {';
echo 'var cvr = document.getElementById("cover")';
echo 'var dlg = document.getElementById(el)';
echo 'cvr.style.display = "block"';
echo 'dlg.style.display = "block"';
echo 'if (document.body.style.overflow = "hidden") {';
echo 'cvr.style.width = "100%"';
echo 'cvr.style.height = "100%"';
echo '}';
echo '}';
echo 'function closePopUp(el) {';
echo 'var cvr = document.getElementById("cover")';
echo 'var dlg = document.getElementById(el)';
echo 'cvr.style.display = "none"';
echo 'dlg.style.display = "none"';
echo 'document.body.style.overflowY = ""';
echo '}';
echo '</script>';
Extra information: The entire page is within the php tags, I found another unrelated function that is behaving the same way. The only way that the two are similar is that they both use the var command and they are all functions. Could this be the source?
echoto a single line. You need to either add semicolons or newline characters to the strings you're outputting.