How do I use two submit buttons, and differentiate between which one was used to submit the form? [duplicate]

Give each input a name attribute. Only the clicked input‘s name attribute will be sent to the server. <input type=”submit” name=”publish” value=”Publish”> <input type=”submit” name=”save” value=”Save”> And then <?php if (isset($_POST[‘publish’])) { # Publish-button was clicked } elseif (isset($_POST[‘save’])) { # Save-button was clicked } ?> Edit: Changed value attributes to alt. Not sure this … Read more

Ajax – How refresh after submit

To solve this using jquery I would try this; $(document).ready(function() { $(“#formSearch”).submit(function() { var options = { /* target:”#divResult”, */ success: function(html) { $(“#divResult”).replaceWith($(‘#divResult’, $(html))); }, url: “http://localhost:8081/sniper/estabelecimento/pesquisar.action” } $(this).ajaxSubmit(options); return false; }); }); alternatively, you could get the server to return just the html that needs to be inserted into the div rather than … Read more

HTML form with two submit buttons and two “target” attributes

I do this on the server-side. That is, the form always submits to the same target, but I’ve got a server-side script who is responsible for redirecting to the appropriate location depending on what button was pressed. If you have multiple buttons, such as <form action=”mypage” method=”get”> <input type=”submit” name=”retry” value=”Retry” /> <input type=”submit” name=”abort” … Read more

Avoid Angular2 to systematically submit form on button click

I see two options to solve it: 1) Specify type=”button” explicitly (i think it’s more preferable): <button type=”button” (click)=”preview();”>Preview</button> According to W3 specification: http://w3c.github.io/html-reference/button.html A button element with no type attribute specified represents the same thing as a button element with its type attribute set to “submit”. 2) Use $event.preventDefault(): <button (click)=”preview(); $event.preventDefault()”>Preview</button> or <button … Read more

Multiple submit buttons php different actions

You could add an onclick method to the new submit button that will change the action of the form and then submit it. <script type=”text/javascript”> function submitForm(action) { var form = document.getElementById(‘form1’); form.action = action; form.submit(); } </script> … <form id=”form1″> <!– … –> <input type=”button” onclick=”submitForm(‘page1.php’)” value=”submit 1″ /> <input type=”button” onclick=”submitForm(‘page2.php’)” value=”submit 2″ … Read more

HTML – How to do a Confirmation popup to a Submit button and then send the request?

The most compact version: <input type=”submit” onclick=”return confirm(‘Are you sure?’)” /> The key thing to note is the return – Because there are many ways to skin a cat, here is another alternate method: HTML: <input type=”submit” onclick=”clicked(event)” /> Javascript: <script> function clicked(e) { if(!confirm(‘Are you sure?’)) { e.preventDefault(); } } </script>

How to open a new window on form submit

No need for Javascript, you just have to add a target=”_blank” attribute in your form tag. <form target=”_blank” action=”http://example.com” method=”post” id=”mc-embedded-subscribe-form” name=”mc-embedded-subscribe-form” class=”validate” >

PHP form – on submit stay on same page

In order to stay on the same page on submit you can leave action empty (action=””) into the form tag, or leave it out altogether. For the message, create a variable ($message = “Success! You entered: “.$input;”) and then echo the variable at the place in the page where you want the message to appear … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)