ok so i am trying to do multiple checkboxes that will directed to their own page with a single submit but not working

<form action ="trip1.php" method="post" name="form1">
<p><input type="checkbox" name="agree" /> Auckland</p>
<form action ="trip.php" method="post" name="form2">
<p><input type="checkbox" name="agree" /> North Shore</p>

<p><input type="checkbox" name="agree" /> Waikato</p>
<p><input type="checkbox" name="agree" /> Taranaki</p>
<p><input type="checkbox" name="agree" /> Toupo</p>
<p><input type="checkbox" name="agree" /> Wellington/p>
<p><input type="checkbox" name="agree" /> Bay of Plenty</p>
<p><input type="checkbox" name="agree" /> Manukau</p>
<p><input type="submit" value="submit" onclick="form2.submit();"/></p>

Edited by dean.ong.14

3 Years
Discussion Span
Last Post by diafol

It isn't possible to submit two forms using a common 'submit' button, normally.
You need Javascript form validation to do this. Use the following as an example and customize it to your needs:

$("#yoursubmitbutton").click(function() {
    if($("#checkbox1").prop('checked') == true) $("#form1").submit();
    if($("#checkbox2").prop('checked') == true) $("#form2").submit();
    return false;

There's no need for two forms. A single form will suffice.
The form handler can redirect based on form information received.


This is odd. Are you trying to submit on the strength of one checkbox being selected, so that you go to say the Waikato page or to the Taupo page?

If so, use radiobuttons as opposed to checkboxes.

If you want the summed info from Waikato and Taupo and any other options, then of course, you need checkboxes.
Alternatively, you could use a select dropdown (instead of radiobuttons) or a multiselect listbox instead of checkboxes.

Is the second form displayed on the strength of the result from the first form submission?

Please inform us.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.