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.
You could add a hidden field to the form called
formIdand have PHP echo it back, so that you know from Javascript which form’s results you’re reading:Or you can do the SUBMIT and result display all in jQuery, so that you needn’t reload the page losing your form visibilities.