Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8388579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:30:02+00:00 2026-06-09T18:30:02+00:00

I was cleaning up my code so that it was more uniform. I placed

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:30:03+00:00Added an answer on June 9, 2026 at 6:30 pm

    OH. MY. GOD.

    Is the following “allowed” by your company’s standards?

    echo <<<HTML
    <script type="text/javascript">
        function showPopUp(el) {
            var cvr = document.getElementById("cover")
            var dlg = document.getElementById(el)
            cvr.style.display = "block"
            dlg.style.display = "block"
            if (document.body.style.overflow = "hidden") {
                cvr.style.width = "100%"
                cvr.style.height = "100%"
            }
        }
        function closePopUp(el) {
            var cvr = document.getElementById("cover")
            var dlg = document.getElementById(el)
            cvr.style.display = "none"
            dlg.style.display = "none"
            document.body.style.overflowY = ""
        }
    </script>
    HTML;
    

    Or just:

    <?php
    // some PHP code
    ?>
    <script type="text/javascript">
        function showPopUp(el) {
            var cvr = document.getElementById("cover")
            var dlg = document.getElementById(el)
            cvr.style.display = "block"
            dlg.style.display = "block"
            if (document.body.style.overflow = "hidden") {
                cvr.style.width = "100%"
                cvr.style.height = "100%"
            }
        }
        function closePopUp(el) {
            var cvr = document.getElementById("cover")
            var dlg = document.getElementById(el)
            cvr.style.display = "none"
            dlg.style.display = "none"
            document.body.style.overflowY = ""
        }
    </script>
    <?php 
    //some MORE PHP code...
    

    Because if it is, you would have noticed you’re using an assignment in an if statement:

    if (document.body.style.overflow = "hidden")
    

    should be

    if (document.body.style.overflow == "hidden")
    

    Note: The way you’re doing it prints the entire javascript block on a single line. If you must print it out this way, you have to either add semicolons or newline characters to each string you print, where necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does the following psuedo code accomplish my goal of cleaning up after myself when
While cleaning some code today written by someone else, I changed the access modifier
I've been cleaning up my code and so far so good, and I only
I'm cleaning up some Jquery code. I always read, chaining is good for performance.
I am cleaning up a .cfm file and removing commented out code. I'm not
Me and several other developers are currently cleaning up our legacy code base, mostly
I've been going through the process of cleaning up our controller code to make
I am working on cleaning up a mess that another programmer started. The created
Hey all, I'm working on cleaning up my code from previous semesters. Previously I
The Story After cleaning up my Dreamhost shared server's home folder from all the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.