views:

29

answers:

5
<td colspan="2" align="center"><html:submit onclick= "return validateText()"
            styleId="reject"  > Reject Version </html:submit></td>

i want to write one more onclick event for this button.

please suggest quickly some good examples.

A: 

Just make the validateText() function call another function. The event will fire once, and you can do what you want at that point. You cannot bind two onclick events on the same button, if that is what you are trying to do.

Jon
A: 

You can't add two OnClick events for a single element.

Brissles
ok i will get some other solution
krishna
A: 

Put all onclick events inside the validateText().

function validateText(){
  onclick_1();
  onclick_2();
....
   onclick_N();
}
Waleed A.K.
thanks for the solution
krishna
A: 
function validateText() {
   // Call functionA
   // Call functionB
}

functionA() {}
functionB() {}
Kris Krause
thanks for the solution
krishna
A: 

You could try to add a function encapsulating both calls:

<script>
  function myEventHandler() {
      if(validateText()) {
          theSecondFunction();
          return true;
      }
      return false;
  }
</script>

And call it from your button:

<td colspan="2" align="center"><html:submit onclick= "return myEventHandler()"
            styleId="reject"  > Reject Version </html:submit></td>
Tomas Narros
thanks for the solution
krishna
nice example given
krishna
You're welcome.
Tomas Narros

related questions