Ask If You Are Sure You Want To Submit? Javascript? January 29, 2024 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 } CopyYou 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?');"CopyThe form will only submit if the user clicks "OK". Solution 2: Here is the solution : //other stuff up here - not important echo "<td><formaction='redeem.php'method='post'id='form'><inputtype='hidden'name='redeem'value='1' /><inputtype='hidden'name='id'value='" . $id . "' /><inputtype='submit'name='Redeem'value='Redeem'onclick="return confirm('Are you sure you want to Redeem?')"></form></td>"; } else { echo "<td><formaction='redeem.php'method='post'id='form'><inputtype='hidden'name='redeem'value='0' /><inputtype='hidden'name='id'value='" . $id . "' /><inputtype='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 CopyEdit: Added escaping character in here:Baca JugaFocus Textarea With Caret After Text In Android BrowserJquery/javascript Convert A Plain Text Message Into A Text Input FieldSmoothslides.js Image Preload //other stuff up here - not important echo "<td><formaction='redeem.php'method='post'id='form'><inputtype='hidden'name='redeem'value='1' /><inputtype='hidden'name='id'value='" . $id . "' /><inputtype='submit'name='Redeem'value='Redeem'onclick=\"returnconfirm('AreyousureyouwanttoRedeem?')\"></form></td>"; } else { echo "<td><formaction='redeem.php'method='post'id='form'><inputtype='hidden'name='redeem'value='0' /><inputtype='hidden'name='id'value='" . $id . "' /><inputtype='submit'name='Un-Redeem'value='Un-Redeem'onclick=\"returnconfirm('AreyousureyouwanttoUn-Redeem?')\" ></form></td>"; //other stuff down here - not important CopySolution 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')"> CopyIf 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?") ) { returntrue; } else { // do something returnfalse; } } CopyAnd on the form tag: onSubmit="return my_confirm()"Copy Share You may like these postsUse Jquery To Re-populate Form With JSON DataJquery Filter Script Not Ignoring Diacritics And Not Highlighting String Matches As User Enters Filter Text Into Text Input FieldGet The Value From HTML Form Using JqueryJQuery Methods: Difference Between .submit() Vs .trigger('submit') 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?"