Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    614
    Thanks
    48
    Thanked 64 Times in 64 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    djh101 - cool, I'll give that a shot, thanks!

  • #4
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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);">


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •