Forum Moderators: open

Message Too Old, No Replies

Syntax error in Response.Write

Help locate my error please

         

nwhorton

6:18 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



So I have this large ASP script that basically constructs an HTML table and fills the fields of the table with entries in a database. Simple enough.

In this table I also have a link that will delete entries from the database when clicked. To this link I want to add functionality for a pop-up dialog where the user must confirm that they do indeed want to delete the entry. This is also simply done using some JavaScript like so:


<A HREF="test.htm" onCLick="return confirm('Are you SURE you want to delete this record?')">Delete It!</A>

However, I've encountered a problem when I try to add this code to my existing ASP code instide a Response.Write. I'm guessing my syntax needs to be tweaked due to the quotations or something. Here is the code I tried:


<%
response.write "<a href='/workshops/attend.asp?op1a=Delete&workshop=" & workshopname & "&dt=" & workshopdate & "&email=" & rs3("email") & "' onClick='return confirm('Are you sure you want to delete this entry?')'>Delete</a>"
%>

Can anyone see where I messed up in that code? The delete is still working but the pop-up dialog is not displayed. Alternatively, if someone knows of a better way to do this in ASP please share. Thanks.

TheNige

7:45 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



In the OnClick you have single qoutes and then single quotes again around the confirm text.

Use double-double quotes for the OnClick or anything else you want to put double quotes around

OnClick=""return Confirm('your text')""

celgins

7:50 pm on Jan 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Like TheNige said, you want to use double-double quotes in place where you would normally use a double quote.

Also, I've seen this done with <input> tags as well. A lot of coders think it works better than using the anchor tag.

nwhorton

7:54 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



Thanks for finding that. Worked.