How to have 2 different submit actions?

Results 1 to 3 of 3

Thread: How to have 2 different submit actions?

  1. #1
    JLo Guest

    Default How to have 2 different submit actions?

    I want to make a form that would send to "test1.asp" if the user hits the submit button or "test2.asp" if the user hits a different button. Is this possible? How do I do this?<BR><BR>Thanks,<BR><BR>~jimmy.

  2. #2
    Join Date
    Dec 1969

    Default RE: How to have 2 different submit actions?

    Set up onclick events for each button. In the clientside code, say FormName.Action = "testx.asp", then FormName.Submit (where FormName is the name of your form, and testx.asp is the name of the file you want to send to).

  3. #3
    rgrafe Guest

    Default RE: How to have 2 different submit actions?

    Another variation...I just happen to do this on one of my forms and here is how I did it.<BR><BR>// Here is the code to set the action of the form and to submit the form.<BR><BR>&#060;script&#062;<BR>function setAction(num,form) {<BR> if(num==1){<BR> document.forms[0].action="test1.asp"<BR> }<BR> if(num==2){ <BR> document.forms[0].action="test2.asp"<BR> }<BR> form.submit()<BR>}<BR>&#060;/script&#062;<BR><BR>// I changed the submit button on my form to a regular button (i.e. type="button" instead of type="submit") <BR>// Then each button&#039;s onClick event called the above function.<BR>// Here are how the form and buttons are set up<BR><BR>&#060;form name="YourForm" method="POST" action=""&#062;<BR>------your form elements--------<BR>&#060;input type="BUTTON" value="Go to Test1" onClick="setAction(1,this.form);"&#062;<BR>&#060;i nput type="BUTTON" value="Go to Test2" onClick="setAction(2,this.form);"&#062;<BR>&#060;/form&#062;<BR><BR>

Posting Permissions

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