I have a few pages from each other to interact with page with id load, as below:
inside process.html
<div id="guest_details"> </div>
<div id="first_start"> </div>
<script>
<! -
$('#guest_details').load('?p=guest_details.html');
$('#first_start').load('?p=first_start.html')
$('#guest_details').hide('slow');
$('#first_start').SlideUp('slow')
->
</Script>
inside guest_details.html
<form action="guest_details.php" <form method="POST" id="guest">
<!-- Some cell here -->
<a onclick="$('#guest').submit();" class="button" id="first_start"> <span> <?php echo $button_submit;?> </span> </a>
</Form>
That I want is when the submit button is clicked then:
- data sent to guest_details.php
- If the data has been sent then hide < div id=”guest_details”> < /div>
- showing the show < div id=”first_start”> < /div>
but when I make it like the above, that not work, Could someone give a clue how to correct?
Thanks a lot
Looking at your previous question and your tags, I assume you are not much aware of AJAX.
You need to
1.post the form asynchronously (without reloading the page, using AJAX).
2. On successfully sending the data, do the dom manipulations.
I suggest using jquery for doing an AJAX post.
Here is a sample code, using jquery:-
And your form html inside
guest_details.htmlneeds to be like:-The $.post given above is a very basic AJAX post. You may add further features as give in Jquery Post.
Also if you want to post the entire form, you can refer jQuery Form Plugin
Updates
I think I understood your problem better this time. Inside your update where you say this-
referring to the sections as
guest_detailsandfirst_startwould make more sense becauseguest_details.htmlmay mean the pageguest_details.htmlwhich you might have opened in another window.Anyway, I am sure you mean the sections inside the page
process.htmlas you have used jquery.load(). Let’s call thefirst_start.htmlandguest_details.htmlas sectionsfirst_startandguest_detailsrespectively.As per your updates do you mean the following:-
Initial state
Section
guest_detailsis shown andfirst_startis hiddenCases/Situations
When form inside
guest_detailssection is submitted, then hide the sectionguest_detailsand showfirst_startsection.At this state when
guest_detailsis hidden andfirst_startis shown, the button onfirst_startcan be clicked and on doing so theguest_detailssection shows again.During these states where one section is hidden and another is shown reloading/refreshing the page should preserve the states.
If above is the complete scenario, here is the code:-