General discussion

Locked

Handling multiple submits in a single form with PHP

By RexWorld ·
article root

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Anyone used this alternate approach?

by RexWorld In reply to Handling multiple submits ...

One possible alternative way of dealing with multiple-button forms is to attach an onClick() event handler to each button that changes the form <action> through JavaScript. So instead of using a single PHP script, you could actually have different scripts for different actions, with JavaScript taking care of changing the form action using code like this:

<input type="submit" onClick="document.forms[0].action='action1.php'">
<input type="submit" onClick="document.forms[0].action='action2.php'">
...

and so on. Has anyone tried this, and what were the results?

Collapse -

RE:Alternate Approach

by billc In reply to Anyone used this alternat ...

If javascript is disabled, the fail-over method would require you to handle both of the submit buttons in the form's action url anyway.

Back to Desktop Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums