Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting up Multiple Submit buttons on a page

Status
Not open for further replies.

mak2112

IS-IT--Management
Aug 8, 2001
46
I am doing a webpage where there is two different ways for a user to log in. I was wondering if it is possible to have two distinctly different Submit buttons. Currently i have one that works and passes inforamtion to the next page correctly, but i cannot figure out how to set the other button to act like a submit botton. Can I have two submit procedures on one page?

thanks
marc
 
You can have two submit buttons, but you'll need to figure out which one was pressed. Alternatively, you can have a regular button that calls a function to submit the form. It can even pass a parameter to the function so you know which button was pressed. Something like this:
Code:
function doSubmit(where) {
   if ( where == "1" )
      document.formname.action = "someURL";
   else
      document.formname.action = "someOtherURL";
   document.formname.submit();
   return true;
}
...
<input type=&quot;button&quot; name=&quot;sub1&quot; value=&quot;Form 1&quot; onClick=&quot;doSubmit('1')&quot;>
<input type=&quot;button&quot; name=&quot;sub2&quot; value=&quot;Form 2&quot; onClick=&quot;doSubmit('2')&quot;>
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top