Ask If You Are Sure You Want To Submit? JavaScript? August 21, 2022 Post a Comment I currently have this. //other stuff up here - not important echo ' Solution 1: You can use the Javascript confirm function. if(confirm("Are you sure you want to Redeem?")) { // do something } else { // do something } Copy You can also do this on form submit by adding the following code to your form: onsubmit="return confirm('Are you sure you want to Redeem?');" Copy The form will only submit if the user clicks "OK". Solution 2: Here is the solution : //other stuff up here - not important echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='1' /><input type='hidden' name='id' value='" . $id . "' /> <input type='submit' name='Redeem' value='Redeem' onclick="return confirm('Are you sure you want to Redeem?')"></form></td>"; } else { echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='0' /><input type='hidden' name='id' value='" . $id . "' /> <input type='submit' name='Un-Redeem' value='Un-Redeem' onclick="return confirm('Are you sure you want to Un-Redeem?')" ></form></td>"; //other stuff down here - not important Copy Edit: Added escaping character in here:Baca JugaHow To Get The Next Obj When Looping In The Django ModelLooping Using Position Absolute To Form 9 BoxesShow And Hide Element On Mouse Over Jquery //other stuff up here - not important echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='1' /><input type='hidden' name='id' value='" . $id . "' /> <input type='submit' name='Redeem' value='Redeem' onclick=\"return confirm('Are you sure you want to Redeem?')\"></form></td>"; } else { echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='0' /><input type='hidden' name='id' value='" . $id . "' /> <input type='submit' name='Un-Redeem' value='Un-Redeem' onclick=\"return confirm('Are you sure you want to Un-Redeem?')\" ></form></td>"; //other stuff down here - not important Copy Solution 3: Use the javascript confirm function. The form won't submit if the confirm returns false. <form action='redeem.php' method='post' id='form' onSubmit="return confirm('Are you sure you want to redeem')"> Copy If you want to do something else if the user clicks cancel then you'll need to create a custom function: function my_confirm() { if( confirm("Are you sure you want to redeem?") ) { return true; } else { // do something return false; } } Copy And on the form tag: onSubmit="return my_confirm()" Copy Share You may like these postsImage Pixel X,y Coordinates To Lat/lonHow To Embed Pdfs That Work In All Web And Mobile BrowsersHow To Add Wordpress Phpshortcode Into Html Page Or Custom Template?Facebook Php Sdk V4.0 Facebookjavascriptloginhelper Return State Null Post a Comment for "Ask If You Are Sure You Want To Submit? JavaScript?"
Post a Comment for "Ask If You Are Sure You Want To Submit? JavaScript?"