Current Affairs

This section takes on the latest happenings. The topics range from macroscopic national and international issues to microscopic issues of society around us.

Entertainment

This part of the spirit lightens you up with poetry,arts and culture, discussions on books, movies, music and video games.

Lifestyle

This section updates you on all latest gadgetry, style statements, games and fashion trends in all dimensions of human life. The aim of this section is to make you “Gaudy and Pompous”

Sports

Regular dose of happenings in the field of sports. Plus history and facts about the games people play.

Tech

Articles that would satisfy the geek in you. Everything from gadgets to software, coding to designing or internet to games. Plus tutorials, faq’s and tips and tricks as well.

Home » Tech

How to add Javascript Confirm Popup Alert

Submitted by Ankit Sabharwal on June 12, 2009 – 10:36 pm7 Comments

javascriptYesterday I was writing a script to delete data from a database. The script was simple, show user the list of articles and and clicking on the delete button it deletes the article.

But then I thought it would be neat to add the same functionality that Wordpress has. It always confirms before deleting any post. Now the easiest way to do it is write some Javascript code.

<script type=”text/javascript”>
var reply = confirm (“Do you want to delete this article ?”)
if (reply)
//write the delete script here
<?php
delete from table where id=10;
else
//do nothing
</script>

Now what is does is it shows a confirm box. Reply will get a value YES if the user clicks on the ‘Yes’ option, otherwise it gets a NO value.

Peace.

7 Comments »

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.