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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Post multiple pages depending on the submit used on a form Possible? 1

Status
Not open for further replies.

Knexo10

IS-IT--Management
Feb 12, 2002
20
0
0
AU
Is it possible to have different buttons on the same from submit to different pages?

At the moment my form is coded like

<form name=&quot;orderForm&quot; action=&quot; method=&quot;post&quot;>

This means that all submit buttons will go to
I want to be able to select other destinations for the submit action to go to. Is this possible????
 
I believe you could also change your submit button to redirect to the new page you would want to go to. For each submit button, change the ONCLICK event to go to the new URL instead of wherever the main form would otherwise take it. Hope this helps.
 
I would like to have the data from a form posted to two different mysql databases from one submit button. Is it possible to do this??

I noticed a post to submit to different pages using different buttons, but I want only one button.

Thanks.

J. Engel
 
Yes. Since you mention "MySQL", I assume you're working with PHP. Have the form submit to a page called, for example, "handlesubmit.php".

On this page, You can parse data, change data, do whatever's necessary, and then connect to your database(s) and do as many insert, delete, select, update, and alter statements as you feel necessary.

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
You could also take the action out of the form tag entirely, use an input button instead of a submit button, and in the button's onClick handler call a function that determines where to send the form, then sets the form's action property accordingly and calls the forms submit method. Something like this:
Code:
function subButton() {
  if ( [i]some condition[/i] )
    document.myform.action = "[i]some url[/i]";
  else
    document.myform.action = "[i]another url[/i]";
  document.myform.submit();
}


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
...except that in many document definitions, action is a required attribute.

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Is action is a required attribute in your document definition, put one in. Nothing in the docdef says it has to be valid, or that you cannot change it, does it?


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
no, you can definitely change it.

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Sometimes the answer to a problem is so obvious we just don't see it.

I never thought of opening a second data base in the php code.

Thanks for all your help.

J. Engel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top