How to call JavaScript function from PHP then act on return value -
this question has answer here:
i creating simple discussion forum, users can create posts, reply posts, delete posts, etc. having trouble deleting posts. can write php delete posts fine, @ moment post instantly deleted (so if clicks accidently have no opportunity cancel). want call javascript function display confirm box php, if function returns true delete post, otherwise nothing. in pseudocode, want is:
<?php function display_javascript_confirm_box() { if(call_javascript_function()==true) { delete();//call php function delete post } else { return false; //do nothing } } ?>
the easiest way otherwise: confirm via js, , delete via php )
<a href="/path/to/delete" onclick="return confirm('do want delete?');">delete</a>
link folowed if user confirms ok in dialog box.
Comments
Post a Comment