HighDots Forums  

Quick newbie question

Javascript JavaScript language (comp.lang.javascript)


Discuss Quick newbie question in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bob
 
Posts: n/a

Default Quick newbie question - 12-02-2003 , 02:46 PM






I would like a small JavaScript to display a warning when a link is pressed
to ask the user if they are sure they want to follow the link.

This is because I am using the link to delete a record from a database using
php and mysql.

Any help would be very welcome as I hav never used JavaScript before.

Thanks

Ben



Reply With Quote
  #2  
Old   
kaeli
 
Posts: n/a

Default Re: Quick newbie question - 12-02-2003 , 03:04 PM






In article <3fccec0d$0$66032$65c69314 (AT) mercury (DOT) nildram.net>,
spam (AT) wrathofthebarclay (DOT) co.uk enlightened us with...
Quote:
I would like a small JavaScript to display a warning when a link is pressed
to ask the user if they are sure they want to follow the link.

This is because I am using the link to delete a record from a database using
php and mysql.

Any help would be very welcome as I hav never used JavaScript before.

This is very dangerous if you don't know your users - they could easily
disable javascript or have non-js text browsers, such as lynx.
My personal way of deleting/updating records involves a confirm page
with a redirect so the users can't refresh or go back and muck things
up.

Anyway...
For modern browsers that support onClick for anchors (NN6/IE5/etc)...

<a href="someUrl" onClick="return confirm('Are you sure?');">link</a>

--
--
~kaeli~
You feel stuck with your debt if you can't budge it.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace



Reply With Quote
  #3  
Old   
Brian
 
Posts: n/a

Default Re: Quick newbie question - 12-02-2003 , 03:08 PM



confirm


"bob" <spam (AT) wrathofthebarclay (DOT) co.uk> wrote

Quote:
I would like a small JavaScript to display a warning when a link is
pressed
to ask the user if they are sure they want to follow the link.

This is because I am using the link to delete a record from a database
using
php and mysql.

Any help would be very welcome as I hav never used JavaScript before.

Thanks

Ben





Reply With Quote
  #4  
Old   
David Dorward
 
Posts: n/a

Default Re: Quick newbie question - 12-02-2003 , 03:14 PM



bob wrote:

Quote:
I would like a small JavaScript to display a warning when a link is
pressed to ask the user if they are sure they want to follow the link.
onclick="return confirm('Sure?');"

Quote:
This is because I am using the link to delete a record from a database
using php and mysql.
You should use POST requests if you plan to make a request which is going to
change something - so you should use a form for this, not a link.

--
David Dorward <http://dorward.me.uk/>


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.