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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:03:30+00:00 2026-05-25T18:03:30+00:00

may i get the jquery-ajax equivalent of this code? thanks <html> <head></head> <body> <?php

  • 0

may i get the jquery-ajax equivalent of this code? thanks

<html>
<head></head>
<body>

<?php
/* if the "submit" variable does not exist, the form has not been submitted - display initial page */
if (!isset($_POST['submit'])) {
?>

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    Enter your age: <input name="age" size="2">
    <input type="submit" name="submit" value="Go">
    </form>

<?php
    }
else {
/* if the "submit" variable exists, the form has been submitted - look for and process form data */
    // display result
    $age = $_POST['age'];
    if ($age >= 21) {
        echo 'Come on in, we have alcohol and music awaiting you!';
        }
    else {
        echo 'You're too young for this club, come back when you're a little older';
    }
}
?>

</body>
</html>
  • 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-25T18:03:31+00:00Added an answer on May 25, 2026 at 6:03 pm

    Phew, I just whipped this up:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    </head>
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script>
    
    $(document).ready(function() {
    
    $("#go").click(function() {
        var age = $("#age").val();
        if(age >= 18) {
            document.getElementById('pre').style.display = 'none';
            document.getElementById('post_good').style.display = 'block';
        } else {
            document.getElementById('pre').style.display = 'none';
            document.getElementById('post_bad').style.display = 'block';
        }
    })
    })
    </script>
    <body>
    
    <div id="pre">
    <form action="" method="post">
    Enter your age: <input name="age" size="3" maxlength="2" id="age">
    <input type="button" name="submit" value="Go" id="go">
    </form>
    </div>
    
    <div id="post_good" style="display:none;">
    Come on in, we have alcohol and music awaiting you!
    </div>
    <div id="post_bad" style="display:none;">
    Sorry, You're too young! 
    </div>
    
    </body>
    </html>
    

    I assume that you were looking for a solution that doesn’t require a new pageload.

    I don’t want to just give you the answer without an explanation:
    The page simply contains all the information you wish to display, but keeps it hidden in a div. When you enter your age, the jquery simply ‘unhides’ the correct div.

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

Sidebar

Related Questions

I'm just starting to get into jquery/javascript programming so this may be a beginner
I'm having a real trouble to get accents right, and I believe this may
As the title may suggest, I have been using jQuery AJAX to try and
I have an ajax call (JSONP) using JQuery with GET method. I think because
I have Cascading Dropdowns, populated via jquery ajax. Follow the link to get the
$.get(/ajax-terms.asp, function(d){ $(#wrap-terms).html(d); }) When the terms data is included directly into the document
In my jquery admin application I quite often get ajax status lingering, there are
How may one get information that was used to programatically generate asp controls? For
Touch may specify self to get the touch location in its own coordinate system
The title may not really explain what I'm really trying to get at, couldn't

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.