Hi Everyone,
I am using javascript code for removing some records. When i am click on delete selected button. I want this should demand one confirm button in which i want if we click OK in confirm box then the record should be removed from database and if i will click on CANCEL button then it should not be removed that record.
I have used some code for this but in this case when i click on CANCEL button after that this is also removing records that i does not want.

So i am sending code for javascript which i am using for this. Please help me what code i should use for this application.

here is code which i am using:----

function validate()
{
 var confirmMessage="Are you sure to Delete these Details from Database ! " ;

  if(confirm(confirmMessage)==false)
  {
      
	 return false;
	  
      }
    }

and this is delete button which i am using in my code: <input name="Delete" type="submit" class="footerlink" value="Delete Selected" onClick="return validate()"> Please help me what javascript code i should use for this. It is very urgent for me.
Thanks,
Gagan

Do it this way:

<html>
<head>
<title></title>
<script type="text/javascript">
<!--
function validate( form ) {
   if ( !confirm("Are you sure to delete these details from database?") ) {
      return false;
      } else { return true;
   }
}
// -->
</script>

</head>
<body>
<form action="process.php" method="post" id="form1" onsubmit="return validate( this );">
<div>
<input type="submit" value="submit" id="sbm" name="sbm" />
</div></form>
</body>
</html>

that's way over-complicated the function. You don't need to pass the form and you don't need if-blocks

function validate()
{
  return confirm("Are you sure to delete these details from database?");
}
This article has been dead for over six months. Start a new discussion instead.