0

I would like to make as my title says, I want to send form´s info to two different pages.

My intention is:

If someone choose one option in the form I want to send the information to page1, but if they select other option I want to send that info to another page. Using only a single button.

Is that possible?

I found info about submit the form two different page but using two button and I want do it only in a single button.

I appreciate any help.

MattC
  • 3,984
  • 1
  • 33
  • 49
laluk
  • 37
  • 1
  • 1
  • 8
  • I have edited your question. Please see [Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles), [Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts) – huMpty duMpty Dec 13 '13 at 10:45

2 Answers2

1

You can achieve this behaviour by changing the form's action, cf this question: javascript - change form action based on selection?

Community
  • 1
  • 1
LoicAG
  • 603
  • 3
  • 19
1

Sure, just use prop() and change the "action" property of the form:

<script type="text/javascript">
    $(document).ready(function() {
        $('#post-to-bar').change(function() {
            var action = 'foo.php';
            if ($(this).is(':checked')) {
                action = 'bar.php';
            }

            $('#my-form').prop('action', action);
        });
    });
</script>

<form action="foo.php" method="post" id="my-form">
    <input type="checkbox" id="post-to-bar" />
    <input type="submit" value="Submit!" />
</form>
h2ooooooo
  • 39,111
  • 8
  • 68
  • 102