Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

href onClick problem

Status
Not open for further replies.

cruford

Programmer
Dec 6, 2002
138
US
I have a hyperlink on one of my pages like this:

Code:
If Request.Cookies("Groups")("DomainAdmins") = "YES" Or Request.Cookies("Groups")("Med4_ITDept") = "YES" Then
Response.Write "<li><a onClick=""Del_OnClick()"" href=""../Information_Technology/Emp_Information.asp?CMD=Delete&ID=" & sID & "&" & uUrl & """>Delete</a><br>"
Response.Write "<li><a href=""../Information_Technology/Emp_Information.asp?CMD=Edit&ID=" & sID & "&" & uUrl & """>Edit</a><br>"
End If

I need to add this client side script:

Code:
<script language="vbscript">
	Sub Del_OnClick
		Dim intResp
		intResp = MsgBox("Do you really want to delete this user?", vbYesNo,"Confirm Delete"
		If intResp = vbYes Then
			window.event.returnvalue = True
		Else
			window.event.returnValue = False
		End If
	End Sub
</script>

How do I add this to the onClick of a <a href> tag? I have tried

Code:
			If Request.Cookies("Groups")("DomainAdmins") = "YES" Or Request.Cookies("Groups")("Med4_ITDept") = "YES" Then
				Response.Write "<li><a onClick=""Del_OnSubmit()""  href=""../Information_Technology/Emp_Information.asp?CMD=Delete&ID=" & sID & "&" & uUrl & """>Delete</a><br>"
				Response.Write "<li><a href=""../Information_Technology/Emp_Information.asp?CMD=Edit&ID=" & sID & "&" & uUrl & """>Edit</a><br>"
			End If

This does not work, anyone have any ideas. Basically I want a msgbox asking for confirmation of the delete, if the user clicks no I need the hyperlink to stop and not process. If they click yes, the hyperlink finishes and deletes the record.
 
Why not just include the redirect within the client side script? Then, get rid of the href parameter in the <a> tag. Would that work? I am more familiar with JavaScript and could easily write you some code to do it via JS.

-Greg
 
I figured it out, it helps if I have all my syntax correct. I was missing some ")" in my clientside script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top