Javascript Simulate Pressing Enter In Input Box
I have what seemed to be a simple fix to a problem but after trying a ton of different solutions online nothing seems to work for me. I have search field that searches a data table
Solution 1:
Try this
document.getElementById("formId").submit();
Solution 2:
You can call the onchange()
event in javascript:
<script type="text/javascript">
window.onload = (function() {
document.getElementById('search').value = " <?php echo $search;?>";
document.getElementById('search').onchange();
});
</script>
This answer also has an alternative: https://stackoverflow.com/a/3629423/890726
Solution 3:
I assume you have a form, the enter in the textbox will trigger the submit of the form. In javascript you can do this manually like this:
<form id='myform" action="/foo">
document.forms["myform"].submit();
Solution 4:
<input type="text" id="fname" onblur="businessFun()">
Please try this and in js buinessFun() do the search actions if you use ajax pass current time as parameter
Post a Comment for "Javascript Simulate Pressing Enter In Input Box"