Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-30-2011, 12:47 AM   PM User | #1
dca_steve
New to the CF scene

 
Join Date: Jul 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
dca_steve is an unknown quantity at this point
Need help with multiple forms

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);">
<fieldset>
<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>
<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" />
</div>
</fieldset>
</form>
</div>
dca_steve is offline   Reply With Quote
Old 07-30-2011, 04:45 AM   PM User | #2
djh101
Regular Coder

 
djh101's Avatar
 
Join Date: May 2009
Location: Santa Clarita
Posts: 603
Thanks: 48
Thanked 63 Times in 63 Posts
djh101 is an unknown quantity at this point
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).
PHP Code:
<div id="forma" style="<?php if($_POST['form'] != "A") echo "display: none;"?>">
...
</div>
Also, if you could wrap your code in code tags, it would make it easier to read.
__________________
"Yeah science!"
Online Science Tools
djh101 is offline   Reply With Quote
Old 08-01-2011, 04:40 PM   PM User | #3
dca_steve
New to the CF scene

 
Join Date: Jul 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
dca_steve is an unknown quantity at this point
djh101 - cool, I'll give that a shot, thanks!
dca_steve is offline   Reply With Quote
Old 08-02-2011, 07:25 PM   PM User | #4
dca_steve
New to the CF scene

 
Join Date: Jul 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
dca_steve is an unknown quantity at this point
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);">
dca_steve is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:29 AM.


Advertisement
Log in to turn off these ads.