...

View Full Version : two onClicks at once?



angst
12-29-2005, 05:16 PM
Hello!

I'm trying to run two onClick(s) at one time,, but only the first one is being hit,

my code


<input type="button" value="Delete" onClick="return confirm('Are you sure you want to delete this file?');" onClick="location.href='?action=del&id=<%=request("id")%>'" class="buttons" />


how can I make both work?
so that on the confirm if you OK, it will continue with the url?

thanks in advance for your time!
-SiX

vwphillips
12-29-2005, 05:25 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
</head>

<body>
<input type="button" value="Delete" onClick="zxc=confirm('Are you sure you want to delete this file?'); if (zxc){window.top.location.href='http://www.vicsjavascripts.org.uk'; }" class="buttons" />
</body>

</html>

konithomimo
12-29-2005, 05:36 PM
You cannot have two (seperate) onClick calls (actually any type of method call) within the same tag. To run two function calls onClick just seperate the funciton calls with a semicolon, but inside the same onClick:

onClick="return confirm('Are you sure you want to delete this file?');" onClick="location.href='?action=del&id=<%=request("id")%>'"

should be:


onClick="return confirm('Are you sure you want to delete this file?');location.href='?action=del&id=<%=request("id")%>'"

angst
12-29-2005, 05:38 PM
kool,
that works:thumbsup:

thanks!

-SiX



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum