troubleshooting Question

JavaScript - add a second onClick event to a form button?

Avatar of sabecs
sabecs asked on
7 Comments1 Solution2618 ViewsLast Modified:
how can I add a second onClick event to my form button?
I want checkFields() to run first and if returns true then redirect to process_payment.php page?



<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
  <script language="JavaScript" type="text/javascript" >
  var clickcount = 0;

   function checkFields(){
     if (clickcount == 0) {
       //count clicks 
       clickcount ++;
       return true;
     else {
       alert("Transaction is in progress.");
       return false;




<input type="button" class="button green" onClick="location.href='process_payment.php?cartId=<?php echo $cookie;?>'" value="Process Order" >

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros