Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Quick newbie question

Reply
Thread Tools

Quick newbie question

 
 
bob
Guest
Posts: n/a
 
      12-02-2003
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
 
 
 
 
kaeli
Guest
Posts: n/a
 
      12-02-2003
In article <3fccec0d$0$66032$>,
enlightened us with...
> 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
 
 
 
 
Brian
Guest
Posts: n/a
 
      12-02-2003
confirm


"bob" <> wrote in message
news:3fccec0d$0$66032$ ...
> 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
 
David Dorward
Guest
Posts: n/a
 
      12-02-2003
bob wrote:

> 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?');"

> 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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick question, hopefully quick answer. ~misfit~ NZ Computing 114 01-06-2005 01:36 PM
Quick question, hopefully quick answer. ~misfit~ NZ Computing 0 12-28-2004 11:55 PM
Quick Question Quick Answer JKop C++ 11 05-24-2004 09:46 PM
Quick Restore for a Compaq not so quick! Croos Bustamunky Computer Support 2 05-15-2004 04:17 AM
PanasonicBQ390 "quick" charger - How quick? Ol' Bab Digital Photography 1 01-17-2004 06:54 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57