PDA

View Full Version : Confirm windows is not working


paulafernandes
12-16-2002, 11:09 AM
Hello!
I have this question that I'm sure is very simple and basic, but I'm not understanding...

I have this piece of code:

function linkform_rem() {
if (confirm("Are you sure?"))
{this.location = "dg_rem_val.asp";}
else { this.location = "dg_rem_cons.asp"; }
}

When I press OK, it goes to "dg_rem_val.asp", but when I press CANCEL it goes to "dg_rem_val.asp" too! I can't go to "dg_rem_cons.asp".

Why??? What am I doing wrong?

Thank's...
Paula

Leon
12-16-2002, 11:33 AM
Hi Paula

Your sample works just fine on mine site.

May be you have some redirect from your second page?
Try to use alert to check result of confirm befor changing location.

paulafernandes
12-16-2002, 11:45 AM
Ok, I found an error...

On my form I had: action = "dg_rem_val.asp" and I was calling onsubmit the funcion linkform_rem();

That's why It goes to "dg_rem_val.asp". Of course...

But now I removed "action" and leaved the onsubmit function.
And it doesn´t do anything! It doesn´t go anywhere...

I´m sorry if this is a very simple thing, but I'm not use to work with Javascript...

Thank's a lot
Paula

Adam20002
12-16-2002, 12:39 PM
Hi Paula,


function linkform_rem() {
if (confirm("Are you sure?"))
return true;
else
{
this.location="dg_rem_cons.asp";
return false;
}


then in your form


<form action="dg_rem_val.asp" ...... onSubmit="return linkform_rem();">

paulafernandes
12-16-2002, 03:10 PM
It worked Perfectly!!!!

Thank's a lot!

Paula