I have a page with a button that is hiding a form with some jQuery when clicked:
<a id="customise" class="configure-demo" href="#">Configure new system & get quote</a>
With the jQuery to hide it being this:
<script type="text/javascript">
jQuery(document).ready(function( $ ) {
$("#customise").click(function(){
$(".entire_product").hide();
$(".customise").show();
});
});
</script>
This hides what is initially on the page and shows a hidden step by step form. There will be several steps but each time next is clicked the page reloads and the next step shows
<div class="customise" style="display:none;">
<form class="form" method="POST" action="<?php the_permalink(); ?>">
<? if (!$_POST['step']) { ?>
<input type="hidden" name="step" value="1" />
Step 1 info.
<? } else if ($_POST['step'] == 1) {
foreach($_POST as $name => $value) {
if ($name <> "step") { echo "<input type=\"hidden\" name=\"$name\" value=\"$value\" />"; $field .= $name."=".$value."&";}
} ?>
<input type="hidden" name="step" value="2" />
Step 2 info
<? } else if ($_POST['step'] == 2) { //do stuff
echo "Do stuff here";
} ?>
</form>
</div>
The problem is when you click next on the form, it reloads the page (as it should) but the form is then hidden again until the button at the top of the question is clicked, then it shows the next step.
How can I show step 2 of the form whilst showing the hidden form on reload?
Obviously if the user isn't in the form process then it should keep the form hidden.