#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171

    Having multiple forms in a page


    Hello;

    What is the right way of having multiple forms in a page where each of these forms submit different data ( have different fields ) but at the same time I want them to hold on to the fileds previously from other forms as well

    Example:
    I submit form A. $_POST shows 4 values. Now I submit form B. I want the seond submittion to include what previously was submitted as well. I used hidden input in this example: This page I want the top filter form and the form on the right corner to submit all the values (from both forms) to the page. But at the same time when u click on Sign In, the other form does the login things.

    The whole <form> tag becomes messy. Any suggestions would be appreciated.
    Thanks
    Last edited by zxcvbnm; April 18th, 2013 at 09:04 PM.
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,997
    Rep Power
    9397
    Where each... what? It's just two forms: the sign in DIV is a form, the search filter is a form.

    And since the sign in form is in its own entire DIV separate from the rest of the page, all (it seems) you need to do is promote the search <form> up in the DOM hierarchy.
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    Originally Posted by requinix
    Where each... what?
    Not sure what happened there, just did the edit.
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,997
    Rep Power
    9397
    Like I said, use one form. When I checked the page earlier I didn't see any reason it wouldn't be possible.
  8. #5
  9. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,653
    Rep Power
    171
    Originally Posted by requinix
    Like I said, use one form. When I checked the page earlier I didn't see any reason it wouldn't be possible.
    This situation happens quite often:
    Code:
    <form>
    	<div>
        	<input>
            <input>
        	<table>
            	<tr>
                	<td>
                    	<form>
                    		<div>
                            	<input>
                                </input>
                            </div>
                        </form>	
                    </td>
                </tr>
            </table>
        </div>
    </form>
  10. #6
  11. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,124
    Rep Power
    4304
    You can not have nested forms.

    As I see it you've got two options. If you want the information to be included in the query string, then you need to use <input type="hidden"> elements. If, however, that doesn't matter, I would recommend that you use server-side session variables (e.g. "$_SESSION" in PHP).
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  12. #7
  13. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Location
    New York
    Posts
    3
    Rep Power
    0
    I think you follow this this simple tip that If you want the information to be included in the query string, then you need to use <input type="hidden"> elements.
    Anyhow thanks for some nice stuff.

IMN logo majestic logo threadwatch logo seochat tools logo