Tag Archives: Jsp

Detect changes in input boxes and persist them via ajax

 

I have a page dynamically created with many input boxes to serve as comments. They are placed side by side with other elements. See photo.

Basic idea is that on blur event (lose focus) or key press enter to update the input box automatically via ajax (no form submit is necessary).

HTML CODE:

In my case this is a JSP page and ${error.id} = 32, ${error.comment} =”123″;

JavaScript for enter key:

JavaScript for persist on blur (inputs are id=32 and oldvalue=”123″):

There is room for improvement, but this functionality serves my purpose