Quick newbie question

Discussion in 'Javascript' started by bob, Dec 2, 2003.

  1. bob

    bob Guest

    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
    bob, Dec 2, 2003
    #1
    1. Advertising

  2. bob

    kaeli Guest

    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
    kaeli, Dec 2, 2003
    #2
    1. Advertising

  3. bob

    Brian Guest

    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
    >
    >
    Brian, Dec 2, 2003
    #3
  4. 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/>
    David Dorward, Dec 2, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wizard
    Replies:
    2
    Views:
    356
    Saravana
    Jan 3, 2005
  2. =?Utf-8?B?UnVkeQ==?=

    Quick Newbie Question

    =?Utf-8?B?UnVkeQ==?=, May 17, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    537
    Scott M.
    May 18, 2005
  3. Starwynd
    Replies:
    1
    Views:
    385
    Tor Iver Wilhelmsen
    Nov 23, 2003
  4. JKop
    Replies:
    11
    Views:
    856
  5. Dilip
    Replies:
    5
    Views:
    312
    Fei Liu
    Apr 21, 2006
Loading...

Share This Page