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 6013101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:30:00+00:00 2026-05-23T02:30:00+00:00

I am wondering whether this is possible: I have a page. The user clicks

  • 0

I am wondering whether this is possible:

I have a page. The user clicks a link and that calls a PHP script. The PHP script returns true or false.

Depending on the true or false, I was hoping to be able to toggle a div.

I am wondering whether I need to do it the AJAX way? How do people usually accomplish this?
Seems pretty common.

I am using this YUI library already:

<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.8.2r1/build/reset-fonts-grids/reset-fonts-grids.css&2.8.2r1/build/base/base-min.css">
  • 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-23T02:30:01+00:00Added an answer on May 23, 2026 at 2:30 am

    Yes, very easy, no need for Ajax. Here’s two ways:

    Using straight PHP:

    <?php
    
    if($test) {
      echo "<div>Content...</div>";
    }
    
    ?>
    

    Or, using inline Javascript (in the PHP script), assuming you have a <div id='targetDiv'> in your HTML, and a $testVar in your PHP:

    <script type='text/javascript'>
    function toggle(testVar) { 
      if(testVar) { document.getElementById('targetDiv').style.display = ""; }
      else { document.getElementById('targetDiv').style.display = "none"; } 
    }
    
    window.onload = function() { toggle(<?php echo $testVar; ?>); } 
    </script>
    

    The second method can be easily altered to degrade gracefully.

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

Sidebar

Related Questions

I was just wondering whether its possible to have something like this: I have
I have no experience with PHP and I am wondering if this is possible:
I'm wondering whether something like this is possible (and relatively easy to do), and
This is a very general question: I was wondering whether it is possible to
I'm wondering whether it's possible to use JavaScript to intercept or prevent the user
I was wondering whether it would be possible to have a ListView, in which
I was wondering whether it's possible to override the arrow key functionality that is
I was wondering whether it is possible to have 2 instances of the camera
I am almost sure that this is not possible, but I'm wondering if someone
I'm wondering whether it's possible to go back to 2 previous page using navigation

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.