Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
We are working on a project where we have to send date and time into database by clicking a button and We have to go to next html page on clicking the same button.

But these two tasks should happen on a single click.

Can this be possible?? If it is, Please help me.
Posted
Comments
Sergey Alexandrovich Kryukov 8-Jun-15 12:21pm    
Define "task"...
—SA

Yes. As many as you want...
JavaScript
<button onclick="do_one(); do_two(); do_more();" />
 
Share this answer
 
Hi,

In order to call two functions add semi-colons (";") to the end of the function call and add new function calls .Something like
<button onclick="one();two();"/>

Please refer below also.
http://www.sitepoint.com/web-foundations/onclick-html-attribute/[^]
 
Share this answer
 
v4
You can try out the following code segment,

XML
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <input id ="btn" type="button" value="click" onclick="event1(), event2()"/>
</body>
</html>

<script type="text/javascript">
function event1() {
  //defination of the event-1
}

function event2() {
  //defination of the event-2
}
</script>
 
Share this answer
 

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