Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a function after textbox lose focus

I have no experience with Javascript/JQuery/AJAX so I'm trying to understand if it's possible to call a function that execute a query on my DB after a textbox lose focus.

I'm displaying a table in my page (using PHP) with text boxes that contains the same values of a table on my DB, and when someone change the value on a text box I want to change the DB table with an UPDATE query to make them equals; is that a way with AJAX or JQuery to do this?

like image 806
Wallkan Avatar asked Jul 28 '12 11:07

Wallkan


People also ask

Which method is triggered when an element loses focus?

The focusout event occurs when an element (or any elements inside it) loses focus. The focusout() method attaches a function to run when a focusout event occurs on the element, or any elements inside it. Unlike the blur() method, the focusout() method also triggers if any child elements lose focus.

Which HTML event occurs when an element on the page loses focus?

The opposite of focus is the blur event, which fires when the element has lost focus.


1 Answers

<input type="text" id="check">​

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<script type="text/javascript">
$("#check").blur(function() {
 alert('working');
});​
</script>
like image 121
Sibu Avatar answered Oct 13 '22 18:10

Sibu