Good day! Tell me how to correctly implement, for example, a request to delete information? There is an icon with a link ?do=edit&id=34 . I wanted to hang up a click event on this link, it ignores and immediately follows it.

  • Does not work. But I understood about the logic, I will understand. Thank you :) - Sai

1 answer 1

 <a href="?remove" onclick="return (confirm('Удалить?'));">[X]</a> 

If the onclick event returns false, no further action is taken. If true or void (i.e., i.e.), the link follows.

 <script type="text/javascript"> var curLink = false; </script> <a href="?remove" onclick="curLink=this;$.jqDialog.confirm('Удалить?',function(){document.location.href=curLink.href;},function(){});return false;">[X]</a> 

Somehow so offhand.

In a separate file:

 var advConfirmLink = ''; function advancedConfirm(link, text) { advConfirmLink = link.href; $.jqDialog.confirm( text, function(){document.location.href=advConfirmLink;}, function(){}); return false; } 

Using:

 <a href="?remove" onclick="return advancedConfirm(this, 'Удалить?');">[X]</a> 
  • I know that. And what about this plugin? kailashnadh.name/code/jqdialog - Sai
  • Wonderful! And another question. How can you put this into a function in a separate file and call it in onclick? Just a lot of similar links and all on different pages. - Sai
  • And I apologize, I have not replaced the variable everywhere. should now. - Sh4dow