gaurih
asked on
call the onclick event inside the input type=submit
This is tricky question but it would be really great If you provide me the solution
I have <input type="submit" onClick="call(parameter)"> . Is thathandle this function from external Jquery function.
Problem is I am not able to click this button since it has already onlcik functionality. Is there any way to do this?
I have <input type="submit" onClick="call(parameter)">
Problem is I am not able to click this button since it has already onlcik functionality. Is there any way to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
in the above code snippet, if the button has onclick event as below
<input type="button" id="btn" value="button click" onclick="submitForm()">
Is that possible to trigger the click from the script and as well as the onclick event?
<input type="button" id="btn" value="button click" onclick="submitForm()">
Is that possible to trigger the click from the script and as well as the onclick event?
Yes it is possible.
Look at below code. First check function is called then click event is fired.
Look at below code. First check function is called then click event is fired.
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Kiran Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<script>
$(document).ready(function(){
$("#txt").keyup(function(){
$("#btn").click();
});
$("#btn").click(function(){
alert("button is click event fired");
});
});
function check()
{
alert("DD");
}
</script>
</head>
<body>
<input type="button" id="btn" value="button click" onclick="check()">
<input type="text" id="txt">
</body>
</html>
OR
If you want to call submitForm() method you can call it within jquery click event as well like below
$("#btn").click(function() {
alert("button is click event fired");
submitForm();
});
So that click event is fired as well as submitForm is called.
If you want to call submitForm() method you can call it within jquery click event as well like below
$("#btn").click(function()
alert("button is click event fired");
submitForm();
});
So that click event is fired as well as submitForm is called.
ASKER
Hi guruvinder,
I tried your sample code, onclick event is removed but alert is not coming for me included in .bind function. am I missing something?
I tried your sample code, onclick event is removed but alert is not coming for me included in .bind function. am I missing something?
please show that code to me
are you placing the code in document.ready or outside?
are you placing the code in document.ready or outside?
button click event is called when text changed in textbox
Demo http://jsfiddle.net/LRYaq/
Open in new window