Confirm function

P

pradeep

Hi

I want output that
There is a link, after clicking on it there is confirm box.
if i click on Ok then it display google.co.in
if i click on Cancel then it display yahoo.co.in

I try my best , but it can't display yahoo.co.in

please guide me.

Thanks in advance.



Code is :

<html>
<head>
<script type="text/javascript">
function confirmation() {

var answer = confirm("Do you want to output ?")

if (answer){
alert("Click on confirm box : Yes")

return true;
}
else{
alert("Click on confirm box : No")
window.location = "http://www.yahoo.com/";
return false;
}
}
</script>
</head>
<body>
<form>
<a href='http://www.google.co.in' onclick="confirmation();">Click me</
a>
</form>
</body>
</html>
 
L

-Lost

pradeep said:
Hi

I want output that
There is a link, after clicking on it there is confirm box.
if i click on Ok then it display google.co.in
if i click on Cancel then it display yahoo.co.in

I try my best , but it can't display yahoo.co.in

please guide me.

Thanks in advance.



Code is :

<html>
<head>
<script type="text/javascript">
function confirmation() {

var answer = confirm("Do you want to output ?")

if (answer){
alert("Click on confirm box : Yes")

return true;
}
else{
alert("Click on confirm box : No")
window.location = "http://www.yahoo.com/";
return false;
}
}
</script>
</head>
<body>
<form>
<a href='http://www.google.co.in' onclick="confirmation();">Click me</
a>
</form>
</body>
</html>

Notice your function returns.

Therefore onclick="return confirmation();"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top