Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need help please. I create html file with 2 tabs. The first tab contains form that takes user input and submit it to php file. I want the result of the php file to be displayed in the second tab. 

HTML file
<ul class="nav">
    <li id="TAB0" class="selected"><a href="#TAB0">Run function</a></li>
    <li id="TAB1"><a href="#TAB1">Results</a></li>
    <li id="TAB2"><a href="TAB2">Help</a></li>
</ul>
<div class="content" id="CONTENT">
    <!--TAB0-->
           <div id = "TAB0" class="active">
            <div class="MainContent">
              <form id='myform' enctype='multipart/form-data' name='myForm'  method='post' action="calculateResults.php">
                      SOME INPUTS HERE
                   <p><input type='button' name="mybut" value='Run'></p>
              </form></div></div>
     <!--TAB1-->
           DISPLAY THE RESULT HERE
     <!--TAB2-->

What is done actually with the above code is display the result in a new window. The php file is already print the output result in some texts and table. I want when I click the button in the first tab to execute .php file and display the result in the second tab not in a new window.

Any help please? 
Thanks, 


What I have tried:

I try the above code but it display the result in a new window.
Posted
Updated 20-Feb-16 22:21pm

1 solution

Instead of calling the PHP script directly from button click event, call a javascript using jQuery's AJAX methods PUT or GET to query the results and write it to a DIV by setting it's innerHTML property.
You'll find a lot of samples on the web - just google for 'AJAX GET'.
 
Share this answer
 
Comments
Member 12341072 21-Feb-16 5:54am    
Do you mean call a javascript using jQuery's AJAX methods from "mybut" button using onsubmit?
if yes, where to put calling the php?

Thanks
NightWizzard 21-Feb-16 7:17am    
You call the PHP script via AJAX PUT or GET method - google for examples, there are a lot showing how to do this. One example will be found here: https://www.quora.com/How-do-I-get-variables-from-PHP-through-AJAX

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900