Kris Fallat
Kris Fallat

Reputation: 1

Submit will not submit the form

I can't seem to get the submit buttons to work. When I click them, they won't do anything at all. They worked, then they didn't. What could the problem be?

<form id="contact" name="updateorder" action="updateorder.php" method="post">
    <h6>Update Order</h6>
	<br>
    <fieldset>
      <input placeholder="Order #" type="text" name="orderid" tabindex="1" id="fieldid" value="<?php echo $_GET['id'];?>" required autofocus>
    </fieldset>
	  <hr><br><br>
		  <fieldset>
  <select name="status" style="width:100%; height:40px;">
  <option value="Received" name="received">Received</option>
  <option value="In Transit" name="transit">In Transit</option>
  <option value="At Store" name="store">At Store</option>
  <option value="Drop Off Location" name="location">Drop Off Location</option>
	<option value="Delivered" name="delivered">Delivered</option>
</select>
    </fieldset>
	  <fieldset>
      <button id='contact' form="updateorder" name="submit" type="submit" data-submit="...Sending">Update Status</button>
		  </fieldset>
	</form>
	<hr>
	  <form id="contact" name="updatetotal" action="updatetotal.php" method="post">
		  <fieldset>
      <input placeholder="Order #" type="hidden" name="orderid" tabindex="1" id="fieldid" value="<?php echo $_GET['id'];?>" required autofocus>
    </fieldset>
	  <fieldset>
		  <input placeholder="Update Total" type="text" name="total">
	  </fieldset>
		  <fieldset>
		<button id='contact' form="updatetotal" name="submit" type="submit" data-submit="...Sending">Update Total</button>
    </fieldset>
  </form>
	<hr><br>
	<form id="contact" name="updatepay" action="updatepay.php" method="post">
 <fieldset>
  <select name="status" style="width:100%; height:40px;">
  <option value="Not Paid" name="notpaid">Not Paid</option>
  <option value="Pending..." name="pending">Pending</option>
  <option value="Paid!" name="paid">Paid</option>
	 </select>
	 <br><br>
	 <fieldset>
		<button id='contact' form="updatepay" name="submit" type="submit" data-submit="...Sending">Payment Status</button>
    </fieldset>
	 </form>

If I could I'd have each button submit on the same form but to a different action, but apparently that isn't possible. So this is the only way I can think of doing it.

Or if I could get one button to update the sql, but I need to specify which one I want to update, and I have no idea how to do that.

Any help is appreciate, thanks guys.

Upvotes: 0

Views: 43

Answers (1)

Ralph Thomas Hopper
Ralph Thomas Hopper

Reputation: 743

well, first of all, an ID is a unique string within a document. having many forms with the same ID is not proper html. if they are styled via their ID, use a class. they still need to have a different ID. also, having buttons with the same ID as their form is also not proper html.

To answer your question, you can submit to different actions based on buttons but you need to handle that in javascript. alternatively, if you NAME your submits with different names (that too by the way should not be the same across controls), you can give them values,

example:

<button id='uniqueID' name="submitPaymentStatus" value="do_paymentStatus" type="submit" data-submit="...Sending">Payment Status</button>

you can then have a single php page as an action and test for that value in the page

if (isset$_POST['submitPaymentStatus']))
    //do whatever you have in updatepay.php

and there you go! if you have questions or need more help let me know!

Upvotes: 2

Related Questions