Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I'm struck with a situation where I need to add more than one javascript to an HTML Textbox.
Is it possible to add more than one javascript to the HTML Textbox.
I'm adding one javascript "onkeypress"

Thank You,
Varun
Posted
Updated 19-Nov-13 0:23am
v2
Comments
Kornfeld Eliyahu Peter 19-Nov-13 6:56am    
You mean more than one function to the same event?
write2varun 19-Nov-13 6:56am    
yes
CodeBlack 19-Nov-13 7:02am    
what do you want to do by calling multiple javascript method on keypress ?

Most probably this would give you some information if this is what you are expecting to,
http://ashishware.com/ASPEventHandlers.shtml[^]

You can also use like this
JavaScript
onClick="doSomething();doSomethingElse();"

Before that refer here for more details.
http://stackoverflow.com/questions/3910736/onclick-multiple-javascript-functions[^]
 
Share this answer
 
It's can't be done on the markup, but using JavaScript itself...

You may use jQuery
JavaScript
$(document).ready(
  function() {
    $("#elementid").click(function() {
      alert("first");
    });

    $("#elementid").click(function() {
      alert("second");
    });
});

Or plain JavaScript
JavaScript
function eventHandler1()
{
  alert("first");
}

function eventHandler2()
{
  alert("second");
}

var el = document.getElementById("elementid");

el.addEventListener("click", eventHandler1);
el.addEventListener("click", eventHandler2);
 
Share this answer
 
v3
Comments
write2varun 19-Nov-13 7:11am    
can you please tell me javascript
Kornfeld Eliyahu Peter 19-Nov-13 7:30am    
see updated solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900