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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:12:28+00:00 2026-06-11T21:12:28+00:00

I have ran out of ideas for this assignment for a class. I had

  • 0

I have ran out of ideas for this assignment for a class. I had to create two PHP forms using PHP_SELF and I am suppose to use javascript or jquery to toggle between the forms. I tried using

<a href="#" onclick="document.getElementById('form1').style.display = 'block'; document.getElementById('form2').style.display = 'hidden';">Form 1</a>
<a href="#" onclick="document.getElementById('form1').style.display = 'hidden'; document.getElementById('form2').style.display = 'block';">Form 2</a>

This does work on changing the forms, however when I hit the submit button the form it goes back to form 1 and doesn’t display the results. The thing I have to figure out is after the form has been submitted using PHP_SELF, how to get it to stay on that form to show the results generated by the server.

  • 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-11T21:12:29+00:00Added an answer on June 11, 2026 at 9:12 pm

    You could add a hidden field to the form called formId and have PHP echo it back, so that you know from Javascript which form’s results you’re reading:

    <?php
        ...
        if (isset($_POST['formId']))
        {
            $show = 'form1' == $_POST['formId'] ? 'form1' : 'form2';
            $hide = 'form1' == $_POST['formId'] ? 'form2' : 'form1';
            // This PHP must be inside the Javascript section of the page, at end.
            print <<<SETVISIBILITY
    
    \$('#$show').style.display = 'block'; // Should be unnecessary (?)
    \$('#$hide').style.display = 'hidden';
    
    SETVISIBILITY;
        }
    ?>
    

    Or you can do the SUBMIT and result display all in jQuery, so that you needn’t reload the page losing your form visibilities.

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

Sidebar

Related Questions

I have been struggling with this for several days now and I ran out
I have ran into an interesting issue while trying to create a more usable
I have ran across a few queries that use this where condition: select ...
Currently developing a PHP framework and have ran into my first problem. I need
I ran out of ideas and couldn't find any reference about it so here
I have tried many different things to do this and all my ideas have
I have built a CMS system using jQuery and PHP, it has worked consistently
I'm writing a C parser using PLY, and recently ran into a problem. This
I'm currently getting to grips with mod_rewrite and have ran into a stumbling block
I'm building a module installer for my CMS and i have ran into a

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.