View Full Version : Need help with multiple forms

Jul 30th, 2011, 12:47 AM
Hi all - I'm having difficulty with the processing of 3 forms on my web page. We'll call my 3 forms A, B, and C.
By default my page shows form A. The other 2 forms I have hidden via display:none
My issue is when I have form B or C showing. Once I hit submit, say within form B for example, I'd like this form to remain for future entries/submital of data. However, instead what happens is form A appears. How do I get form B to remain, allowing for a user to submit multiple entries of data without going back to form A?

Here's my code for form 'B'

<div id="branches_info" style=" <?php echo $display_branches; ?> ">
form method="post" action="annual_report_main.php" onsubmit="return validateBranches(this);">
<p><strong>Branch Location</strong></p><br />
<label for="branch_address" class="long">Street Address:</label>
<input maxlength="50" type="text" name="branch_address" id="branch_address" value="<?php echo htmlentities($_POST['branch_address']);?>" /><br />
<div class="cleaner"></div>
<label for="branch_city" class="long">City:</label>
<input maxlength="20" type="text" name="branch_city" id="branch_city" value="<?php echo htmlentities($_POST['branch_city']);?>" /><br />
<div class="cleaner"></div>
<label for="branch_state" class="long">State:</label>
<input maxlength="2" type="text" name="branch_state" id="branch_state" value="<?php echo htmlentities($_POST['branch_state']);?>" /><br />
<div class="cleaner"></div>
<label for="branch_zip" class="long">Zip Code:</label>
<input maxlength="10" type="text" name="branch_zip" id="branch_zip" value="<?php echo htmlentities($_POST['branch_zip']);?>" /><br />
<div class="cleaner"></div>
<div class="content_onecolumn">
<input type="submit" name="Branches" value="Submit to Database" class="inputSubmit" />
<div class="content_onecolumn">
<input type="button" name="Finished" value="Finished" class="inputSubmit" onclick="window.open('https://www.dca.ca.gov/webapps/bppe/thankyou.php');return false" />

Jul 30th, 2011, 04:45 AM
If you're reloading the page (i.e. not using ajax), you could send a variable stating which form was submitted. On the page load, check the value and hide the other forms accordingly (either with PHP or javascript).

<div id="forma" style="<?php if($_POST['form'] != "A") echo "display: none;"; ?>">

Also, if you could wrap your code in code tags, it would make it easier to read.

Aug 1st, 2011, 04:40 PM
djh101 - cool, I'll give that a shot, thanks!

Aug 2nd, 2011, 07:25 PM
djh101 - I used the code you provided, but for some reason when I access my web page, the form is hidden. I tried a modifying a number of things, but still get a page with no form when I first open the page....somehow the display: none is overriding everything....maybe I don't have this coded right?

Here's the top part of my form:

<div id="header_info" style="<?php if($_POST['form'] != "HeaderInfo") echo 'display: none';?>" >

<form id="HeaderInfo" method="post" action="annual_report_main.php" onsubmit="return validateHeader(this);">