View previous topic :: View next topic |
Author |
Message |
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2196
|
Posted: Fri Sep 02, 2011 1:28 pm Post subject: Using Javascript to Show Confirmation Prompt (solved) |
|
|
I'll try to describe this as best as I can.
I'm writing a page where I want to give the user the option to delete some of their data.
Code: |
<a href="delete.php?record=<?php echo $i; ?>">Delete Record</a>
|
What little javascript code I have looked up either uses a button or depends on the javascript somehow to redirect the browser. If at all possible, I don't want to depend on javascript to make this happen, simply enhance it with a prompt. Can Javascript somehow cancel a link's action in the browser somehow if the user clicks "no"?
Or would a redirect to another page to confirm deletion sound better? (To me kinda sounds clunky.) _________________ "It's ok, they might have guns but we have flowers." - Perpetual Victim
Last edited by Bigun on Fri Sep 02, 2011 2:24 pm; edited 1 time in total |
|
Back to top |
|
|
Dr.Willy Guru
Joined: 15 Jul 2007 Posts: 547 Location: NRW, Germany
|
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2196
|
Posted: Fri Sep 02, 2011 2:00 pm Post subject: |
|
|
Dr.Willy wrote: | http://www.bradino.com/javascript/onclick-return-false ? |
That looks like it will work, but it looks like it is using the Prototype framework. I've never used JavaScript much, let alone a framework based on it. Is there documentation on how to install the framework? It looks like I could use a few functions it offers. _________________ "It's ok, they might have guns but we have flowers." - Perpetual Victim |
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2196
|
Posted: Fri Sep 02, 2011 2:23 pm Post subject: |
|
|
Nevermind, I figured it out. A simple script include in the header of the page "installs" the framework.
Worked like a charm, will be using this in the future quite extensively I'm sure. _________________ "It's ok, they might have guns but we have flowers." - Perpetual Victim |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21602
|
Posted: Fri Sep 02, 2011 11:20 pm Post subject: |
|
|
Support for canceling a click via onclick=handler is native to Javascript and does not require the use of Prototype. (However, using Prototype may make it easier for you to mark up all the links consistently if you generate them from many places.) |
|
Back to top |
|
|
|