Dear All,

I have a problem with delete confirmation code in java script.

i m using this code:

<script LANGUAGE="JavaScript">

function confirmSubmit()
{
var agree=confirm("Are you sure you wish to continue?");
if (agree)
return true ;
else
return false ;

}

</script>

in Asp page on click of hyperlink tage message displays and on click of Cancel the next page is called where as in simple html file hyper tag code acts properly.

please suggest in this regars what i have to day and where i m making mistake

Hi:

The javascript seems to work perfect even in asp page.

I can't find any mistake in the syntax of Javascript.

I presume you are giving link in your asp script like

<a href="nextfile.asp" onclick="confirmSubmit()">Click here</a>

If you are using response.write to generate the hyperlink use chr(34) to produce the double quote character (")

Sharing some more code will help us to guide you better

NR

Dear I m using this script with in ASP file under response.write
as
response.write "<a href='nextfile.asp?mode=delete&id=5' onclick = confirmsubmit()>Delete</a>" if i use in this way message box display but either i click ok or cancel nextfile page is called and there action is performed.
where as if the same code is written in plain html page in simple
<a href="nextfile.asp?mode=delete&id=5" onclick = confirmsubmit()>Delete</a> here it work properly measn in message box if i cancel it remain on the same page.

Pls suggest what is the problem in ASP code format .


Regards,
Needo

Hi,
Use this code

response.write "<a href='nextfile.asp?mode=delete&id=5' onclick='return confirmSubmit()'>Delete</a>"

return is compulsory here as we will need to stop the onclick event.

Dear I m using this script with in ASP file under response.write
as
response.write "<a href='nextfile.asp?mode=delete&id=5' onclick = confirmsubmit()>Delete</a>" if i use in this way message box display but either i click ok or cancel nextfile page is called and there action is performed.
where as if the same code is written in plain html page in simple
<a href="nextfile.asp?mode=delete&id=5" onclick = confirmsubmit()>Delete</a> here it work properly measn in message box if i cancel it remain on the same page.

Pls suggest what is the problem in ASP code format .


Regards,
Needo

Hi:

Just see the post by Vicky.. Follow his guidelines and that should solve your problem.

Cheers

NRV

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.