Message Box

Results 1 to 2 of 2

Thread: Message Box

  1. #1
    Jyotsna Guest

    Default Message Box

    I have a Delete XXX link, which when clicked will delete the particular record. How can I display a message box that asks the user to confirm and based on his action executes the ASP code (deletes the record or returns to the original page). Thanks.

  2. #2
    Nathan Pond Guest

    Default RE: Message Box

    For that type of user interaction, you will need to use some sort of client side scripting. (vbScript or JavaScript) JavaScript would probably be best as it is compatible on more browsers. I don&#039t remember the exact code, and my book is at home so I can&#039t look it up. But I&#039ll give you an example, it may or may not work but it&#039ll give you the idea. The part of JavaScript that I don&#039t remember off-hand is how to get a Yes/No alert box. Here goes:<BR><BR>&#060;HTML&#062;<BR>&#060;HEAD&#062;< BR>...<BR>...<BR>&#060;SCRIPT LANGUAGE=JavaScript&#062;<BR>function doConfirm(obj)<BR>{<BR> var answer;<BR> answer = window.confirm("Are you sure you want to delete this?")<BR> if (answer == true)<BR> location.href = &#039script.asp?del=&#039+obj;<BR> else<BR> return false;<BR>}<BR>&#060;/SCRIPT&#062;<BR>&#060;/HEAD&#062;<BR>...<BR>...<BR>...<BR>&#060;a href="JavaScript:doConfirm(1);"&#062;Delete XXX 1&#060;/a&#062;<BR>&#060;a href="JavaScript:doConfirm(2);"&#062;Delete XXX 2&#060;/a&#062;<BR>&#060;a href="JavaScript:doConfirm(3);"&#062;Delete XXX 3&#060;/a&#062;<BR>&#060;a href="JavaScript:doConfirm(4);"&#062;Delete XXX 4&#060;/a&#062;<BR>...<BR>...<BR>...<BR>&#060;/HTML&#062;<BR><BR>Of course, you have to have some sort of numbering convention for the items you are deleting, like an id field in the table. But your question wasn&#039t on that so I won&#039t go into it. :-) Like I said, don&#039t quote me on the window.confirm, I can&#039t remember if that&#039s it or if you call alert with some other parameter to make it a confirm box. It&#039s been a few years since I&#039ve used one. Let me know if this doesn&#039t work, or there&#039s something you&#039d like me to explain.<BR><BR>Hope I helped<BR><BR>Nathan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •