alert onclick

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

alert onclick

Post by shiznatix »

this is easy but i am the worst at javascript. i want when you click on a link that it will alert saying "you sure you want to delete $variable_name" where variable name is the name of a hidden field. then if they click yes it continues with what it would do but if they click no then it stops and does not go to the link.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

<script type="text/javascript">
<!--

function askOK()
{
    if (confirm('Dude! You sure you are OK with this??!')) return true;
    else return false;
}

// -->
</script>

<a href="somewhere_bad" onclick="return askOK();">Click me</a>
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

oh ok that was easy enough. thanks
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

this confirm command does not work, infact it does nothing. it just goes to the link straight away. hummmm

edit: ahha javascript does not work when you have javascript turned off... hummmmmmm
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

shiznatix wrote:edit: ahha javascript does not work when you have javascript turned off... hummmmmmm
I've done that before now.... I thought I was going mad and then I realised what I was doing :D
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

shiznatix wrote:ahha javascript does not work when you have javascript turned off... hummmmmmm
hey, thats new to me :lol:
Post Reply