📜  如果是,则编写确认对话框,然后使用 php 运行函数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:22.030000             🧑  作者: Mango

代码示例1
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