Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

write confirm dialog box if yes then run function using php

You can handle the attribute onClick for both i.e. 'ok' & 'cancel' condition like ternary operator

Scenario: Here is the scenario that I wants to show confirm box which will ask for 'ok' or 'cancel' while performing a delete action. In that I want if user click on 'ok' then the form action will redirect to page location and on cancel page will not respond.

So below code is working properly for me :
onClick="return confirm('Are you sure you want to Delete ?')?this.form.action='<?php echo $_SERVER['PHP_SELF'] ?>':false;"

Full code
<input type="submit" name="action" id="Delete" value="Delete" onClick="return confirm('Are you sure you want to Delete ?')?this.form.action='<?php echo $_SERVER['PHP_SELF'] ?>':false;">
And by the way I'm implementing this code as inline in html element using PHP. so that's why I used 'echo $_SERVER['PHP_SELF']'.

I hope it will work for you also. Thank You
Comment

PREVIOUS NEXT
Code Example
Javascript :: como hacer un onpress en react native expo 
Javascript :: dustjs compilator 
Javascript :: bundle all css js files 
Javascript :: js remove plus 
Javascript :: latest rn fatch blob package download 
Javascript :: puppeteer print page numbers after second page 
Javascript :: how do i make largest swap javascript stack overflow 
Javascript :: better way of using discord.js 
Javascript :: how-to-avoid-to-exceed-rate-limit-by-using-discord-js-api 
Javascript :: time picker in react example 
Javascript :: how to sort a 2d array in javascript 
Javascript :: pg ssl settings js 
Javascript :: make the background color of page in the loading js 
Javascript :: Back button directive Angular 
Javascript :: validate url javascript 
Javascript :: detect click on link in all places javascript 
Javascript :: cypress chai exclude spectial char when asserting 
Javascript :: react testing library getBy image 
Javascript :: yarn dev error eacces windows 
Javascript :: expo draw over other apps 
Javascript :: Setting Up Multiple Event Responses 
Javascript :: add object to object dynamically 
Javascript :: 8.2. Working With Arrays // Undefined 
Javascript :: javascript substtgin 
Javascript :: How to apply CodeMirror in Bootstrap Modal 
Javascript :: dynamically populate vue material table 
Javascript :: sequelize findall in array 
Javascript :: ternary operator online 
Javascript :: version control api nodejs best practices 
Javascript :: google script delete line 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =