Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

multiple forms on 1 page

Hi

i have a cms and i've been asked to create an email sign up form

the people have given me the code to integrate into their PHP system
the code they gave me is standard HTML which posts to a URL
1 parameter is on the querystring and the other 2 parameter are used on the "post" so they are not contained within the querystring


however, i dont think its as simple as that as asp.net doesn't allow multiple forms

whats a quick easy way to do this?
<form name="form2" id="form2" method="post" action="http://clients.mysender.com/form.php?form=5" target="_blank" >

    <input type="hidden" id="format" name="format" value="h" />
    <input type="text" name="email" value="test@test.com"   id="txtEmail"  class="emailSignUp"  />
    <input type="submit" id="submitBtn" name="submitBtn"   class="emailSignUpButton"   />

</form>

Open in new window

Avatar of Ironhoofs
Ironhoofs
Flag of Netherlands image

ASP.NET does allow multiple forms on one page, but you cant nest them.
Avatar of ajb2222
ajb2222

Forms give you the opportunity to group fields and post only the neccesary data to the attached URL.

Example:




<html>
<body>

<p>Sign in</p>

<form id="form1" action="login.asp" method="post">
  <input type="text" name="user" />
  <input type="password" name="password" />
  <input type="submit"/>
</form>

<p> or sign up for our newsletter</p>

<form id="form2" action="newsletter.asp" method="post">
  <input type="text" name="email" />
  <input type="submit"/>
</form>

</body>
</html>

Open in new window

Ah, forgot about the "one form with runat=server per page" rule...

You can only have several forms on your page, but only one form with "runat=server". Because your second form only uses static data, this should be no problem.

Avatar of websss

ASKER

can i put my non-runatserver form inside the standard runatserver asp.net form?
Avatar of websss

ASKER

ok slight issue
as its in a cms the whole server form needs to be throughout the page so i cant have multiple forms

what other options do i have
ASKER CERTIFIED SOLUTION
Avatar of Ironhoofs
Ironhoofs
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And a 3rd option. This may not work if the server only accpets the "post" action:


<input type="text" name="email" value="test@test.com" id="txtEmail" />
<input type="button" value="Go" id="submitBtn" name="submitBtn" onClick="window.open('http://clients.mysender.com/form.php?form=5&amp;format=h&amp;email=' + document.getElementById('txtEmail').value );" />

Open in new window