views:

64

answers:

3

I had two forms

1.login form
2.Registration form

login form has the username and password fields and registration form consists controls for registration like username, city, country, etc.,

3. Also, i have some hidden controls like 

<input type="hidden" name="ctrl1" />
<input type="hidden" name="ctrl2" />
<input type="hidden" name="ctrl3" />
<input type="hidden" name="ctrl4" />

Which is dynamically generated using PHP Code.

What I want is, When the user click login form's submit or the registration form's submit, the hidden controls data should also be Posted.

Plz help. Any help will be appreciated

+4  A: 

Insert the hidden inputs into both forms when you generate the page:

<form id='form1' action='' method='post'>

<input type='hidden' name='h1' value='v1' />
<input type='hidden' name='h2' value='v2' />
<input type='hidden' name='h3' value='v3' />

<input type='submit' name='submit' value='Submit Form 1' />
</form>

<form id='form2' action='' method='post'>

<input type='hidden' name='h1' value='v1' />
<input type='hidden' name='h2' value='v2' />
<input type='hidden' name='h3' value='v3' />

<input type='submit' name='submit' value='Submit Form 2' />

</form>
fredley
Multiple controls with SAME name dont affect XHTML rules??
Rajasekar
No, only multiple elements with the same ID.
meagar
Then i will try if it works
Rajasekar
I've added an example of how your code should be structured.
fredley
A: 

Use jQuery's serialize on one of the forms.

fabrik
+1  A: 

Dear Raj,

Use this example, definitely it will help you.

<SCRIPT LANGUAGE="JavaScript">
  function runscript()
  {
    document.form1.submit();
    document.form2.submit();
  }
</SCRIPT>
<BODY>
  <FORM METHOD=POST ACTION="http://localhost/login.php" NAME="form1">
    <INPUT TYPE="text" NAME="text1">
  </FORM>
  <FORM METHOD=POST ACTION="http://localhost/register.php" NAME="form2">
    <INPUT TYPE="text" NAME="text2">
  </FORM>
  <INPUT TYPE="button" value="Submit" onClick="runscript()">
</BODY>

All The Best !!!

Rahul Patil