Jump to content

a form with more then 1 action


smartalco

Recommended Posts

No, there's no support for that. You would need to use Javascript if you want to do multiple things. The form action is the page that gets loaded when the form gets submitted, so you can't have the button load two pages, it wouldn't make sense. If you want multiple things to happen you need to use Javascript to send the requests out using something like AJAX.

Link to comment
Share on other sites

No, there's no support for that. You would need to use Javascript if you want to do multiple things. The form action is the page that gets loaded when the form gets submitted, so you can't have the button load two pages, it wouldn't make sense. If you want multiple things to happen you need to use Javascript to send the requests out using something like AJAX.
And how should you do it with Javascript? If I have a form with 2 actions, how will the form know what action I want him to do?
Link to comment
Share on other sites

You can't have 2 actions on a form, you can have 1 at most. If you want multiple things to happen, then have a Javascript function run when you hit the submit button. Before the form submits, you can have Javascript do whatever you want, open up 10 connections with AJAX and send out 10 requests if that's what you want to do, you can do whatever you want in Javascript. But when the Javascript function exits, if it returns a value of true, the form will still only get submitted to the one action.

Link to comment
Share on other sites

Though, still it may be a common situation that in one single form, different 'locations' are to be the target for the submit.I would adjust the form to load a javascript onclick at each button, that changes a value in a hidden field. This field would have a name like "action", "doWhat", "choice", or whatever. And the target of the submit would then react on that value, and proces different actions instead of having two completely different targets for the form.But that way it will turn into a server-side question.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...