How to Save Changes When Leaving a Field With JQuery
The jQuery language provides you with a method that processes forms without requiring the user to refresh the page. You can also process a form after an activity such as leaving the field. The "onmouseout" event triggers when the user tabs to a new field or clicks another item on the Web page. The jQuery language triggers and sends the form data your processing page automatically.
Instructions
-
-
1
Right-click the HTML page that contains your form and select "Open With." Click your preferred HTML editor.
-
2
Create the jQuery function that sends the data to the processing page. The following function sends the form to "processpage.php":
$('onmouseout').function(); ({
type: "POST",
url: "processpage.php",
data: dataString,
success: function() {
$('#success').html("<div id='message'>Your information has been sent</div>");
});In this example, when the user moves away from the form field using the mouse or the tab key, the function process page executes.
-
-
3
Create the div container that displays the results of the submission. In this example, the div container named "success" displays the results when the form finishes processing. Add the following code in the location in which you want to send feedback to the user:
<div id="success"></div>
-
1