Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using Javascript to Show Confirmation Prompt (solved)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Bigun
Advocate
Advocate


Joined: 21 Sep 2003
Posts: 2196

PostPosted: Fri Sep 02, 2011 1:28 pm    Post subject: Using Javascript to Show Confirmation Prompt (solved) Reply with quote

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
View user's profile Send private message
Dr.Willy
Guru
Guru


Joined: 15 Jul 2007
Posts: 547
Location: NRW, Germany

PostPosted: Fri Sep 02, 2011 1:44 pm    Post subject: Reply with quote

http://www.bradino.com/javascript/onclick-return-false ?
Back to top
View user's profile Send private message
Bigun
Advocate
Advocate


Joined: 21 Sep 2003
Posts: 2196

PostPosted: Fri Sep 02, 2011 2:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Bigun
Advocate
Advocate


Joined: 21 Sep 2003
Posts: 2196

PostPosted: Fri Sep 02, 2011 2:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21602

PostPosted: Fri Sep 02, 2011 11:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum