Jump to content

To get confirmation


damini_dd

Recommended Posts

Hello Friends, I am new to java script. I am using it in ASP. In that I got one button to delete record. If I click on delete button it should dispaly window for confirming. I used confirm, but I want cancel to be selected by default. and if user select OK, it should execute my asp script wiht parameter. My code is as below :<img src="button_images/delete.jpg" width="61" height="22" onclick="deleteRec(<%=i%>)"></div><script language="JavaScript" type="text/JavaScript"> function deleteRec(i) { confirm("Are you sure?") if(confirm != 0) { window.location="DeleteTourismData?id=" & i } else { window.location="viewevents.asp" } }thanks

Link to comment
Share on other sites

In an JavaScrips' confirm you can't change the focus of the "OK" button :)I can rewrite your javascript though:

<img src="button_images/delete.jpg" width="61" height="22" onclick="deleteRec(<%=i%>)" /><script type="text/javascript">function deleteRec(num){  if (confirm("Are you sure?"))  { window.location="DeleteTourismData?id=" + num }  else  { window.location="viewevents.asp" }}</script>
Much smaller isn't it :) Edited by Dan The Prof
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...