📅  最后修改于: 2022-03-11 15:01:22.030000             🧑  作者: Mango
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='':false;"
Full code
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