2 requests in onClick

Asked

Viewed 22 times

1

I have an onClick in an image with 2 requests:

1) a check 2) a redirect

function verifica(Msg) {
 return confirm(Msg);
}

And the image:

 <img 
     src="'.$imagemExclui.'"
     align="center" 
     style="height: 40px;" 
     title="Excluir Produto"
     onClick="return verifica(\''.$mensagem.'\');
                     document.location=\'?acao=remove&indice='.$produto["idProdutos"].'\'"; />

But when I call the function checks, if I withdraw the return it works, but even if I select yes, it does not follow, if I leave and return, it doesn’t work.

What to do?

  • Possible duplicate of http://answall.com/q/88536/129

  • For this specific case it is also possible to do: onclick="if(verifica(...)){ document.location=... } instead of return.

  • Perfect Anderson, that’s what I needed. Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.