javascript - Update database when confirm is clicked -
i know how update database when button clicked (if (isset($_post[....
) know how ask user whether wants submit or not form javascript. not know how ask user this, , if he/she clicks on confirming option, database updated.
all can think mixing php , javascript not sound me pleased if can me problem.
thank time
i have tryed following:
<button name="submit_text" onclick="pregunta()">submit text</button> <?php if (isset($_post['submit_text'])) { $sql="update ....... mysqli_query($db,$sql); header("refresh:0"); mysqli_close($db); } ?> <script language="javascript"> function pregunta(){ if (confirm('el texto traducido se enviará al cliente. ¿está seguro?')){ return true; } else { return false; } } </script>
but php executed button clicked no
you can use confirm()
method request confirmation user. returns boolean can use control logic flow. try this:
$('form').submit(function(e) { if (!confirm('are sure want submit form?')) e.preventdefault(); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form> <button>submit</button> </form>
Comments
Post a Comment