damini_dd Posted December 2, 2005 Share Posted December 2, 2005 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 More sharing options...
Jack McKalling Posted December 2, 2005 Share Posted December 2, 2005 (edited) 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 December 2, 2005 by Dan The Prof Link to comment Share on other sites More sharing options...
damini_dd Posted December 2, 2005 Author Share Posted December 2, 2005 In an JavaScrips' confirm you can't change the focus of the "OK" button <{POST_SNAPBACK}> Thanks a lot Link to comment Share on other sites More sharing options...
Jack McKalling Posted December 2, 2005 Share Posted December 2, 2005 You're welcome :) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now