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

  • Home
  • SEARCH
  • 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 4344348
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:53:05+00:00 2026-05-21T11:53:05+00:00

Basically I want to perform this check: var done = <?= $test_details[‘done_test’] ?>; if(typeof

  • 0

Basically I want to perform this check:

   var done = "<?= $test_details['done_test'] ?>";
    if(typeof done == 'undefined'){
    $('WORKING').appendTo('#bodyArea'); // just for testing (code here)
    }

Obviously the check is using a value from an SQL query. So, what I want to do and cant seem to get working is:

on loading page: run query with PHP then run the JQuery which checks result value from query is not NULL.

this is what I have tried:

$(window).load(function () {
 // code here
});

and:

$(document).ready(function () {
    // code here
});

no luck with both.

Many thanks for help.

  • 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-05-21T11:53:06+00:00Added an answer on May 21, 2026 at 11:53 am
    var done = "<?= $test_details['done_test'] ?>";
    if(typeof done == 'undefined'){
       $('WORKING').appendTo('#bodyArea'); // just for testing (code here)
    }
    

    typeof done would never be undefined since you’d always be defining it.

    If you want to run some jquery based on your PHP, you can try this

    <?php if (empty($test_details['done_test'])) : ?>
       <script type='text/javascript'>
           //Code runs ONLY if $test_details['done_test'] is empty
           $(document).ready(function(){
             $('WORKING').appendTo('#bodyArea'); // just for testing (code here)
           });
       </script>
    <?php endif; ?>
    

    This way, the check is done on a PHP variable with PHP. When the page is processed, if the variable is empty PHP will output the JS making it run.

    DEBUGGING

    If you’re still having problems, put the code below and see what happens

    <?php if (empty($test_details['done_test'])) : ?>
       <script type='text/javascript'>
           alert("$test_details['done_test'] is empty");
       </script>
    <?php else : ?>
       <script type='text/javascript'>
           alert("$test_details['done_test'] is not empty");
       </script>
    <?php endif; ?>
    

    If you’re not getting any output, then you’re doing something wrong. We’ll have to see your HTML.

    If your getting that $test_details['done_test'] is not empty message, then that means your earlier code was working properly because it was not executing if the variable was not empty

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

Sidebar

Related Questions

Basically what I'm trying to accomplish is I want to check multiple dynamic forms
I have this controller set up for a login: <?php class Login extends Controller
I'm developing an android app (if you want more info http://www.txty.mobi ) and I
I am working on a project in C#.NET using the .NET framework version 3.5.
Basically, I have a project and a Continuous Integration solution which I have no
I have designed a class which is basically nothing but an object which stores
'm developing a 2D game and I want separate the game engine from the
I have an ASP.NET GridView which displays a list of neighborhoods. I wish a
I am trying to implement a php script which will run on every call
Please bear with me as I'm a bit new to rails (especially rails 3),

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.