You must Sign In to post a response.

How to check if a button is clicked using JavaScript?


Are you looking way to check a button click using JavaSript? Do you want to pass values from JavaSript to server side? Read this thread to know about how to use JavaSript for checking whether a button is clicked.

Friends,

I have two Submit in an asp page for two different client side operation. How can I check which one is clicked by the client using JavaScript.
and Also I want to pass that value to server side for comparison..






Regards
ArunRaj


Comments

#703808    Author: Arvind kumar    07 Feb 2013 Member Level: Gold   Points : 3

Simply you can attach a javascript function in button's click event so once that is clicked that js function will be called and you show messages within that js

eg
in your code
btnUpdate.Attributes.Add("onclick", "buttonClicked()");

In javascript code file
funciton buttonClicked()
{
alert('Button's click event fired');
}

Also you can add click event directly as follows
document.getElementById('button').onclick = function() {
alert("button was clicked");
}?;


Regards & thanks
Arvind kumar
Visit--blog.akumars.esoftera.in


This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.