Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4030086
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:25:38+00:00 2026-05-20T11:25:38+00:00

I’m looking for a way to submit only changed form fields to the server.

  • 0

I’m looking for a way to submit only changed form fields to the server. So, let’s say I have a form

<form>
    <input type="text" name="a"/>
    <select name="b">...</select>
    <input type="checkbox" name="c"/>
</form>

which is populated with certain data already. The user edits the form and clicks submit. If the user only changed input b, then I want to submit only input b. If only a and c were changed, I want to submit only a and c. And so on.

I could write something myself to accomplish this, but I am wondering maybe there is already something out there that I could use? Ideally, I would like the code to be short. Something like this would be perfect:

$('form').serialize('select-only-changed');

Also, I came across this http://code.google.com/p/jquery-form-observe/ , but I see there are issues with it. Is this plugin working solidly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:25:39+00:00Added an answer on May 20, 2026 at 11:25 am

    Another approach would be to serialize the form when the page loads, and then on submit, only submit the changes.

    $(function() {
    
      var $form = $('form');
    
      var startItems = convertSerializedArrayToHash($form.serializeArray()); 
    
      $('form').submit() {
        var currentItems = convertSerializedArrayToHash($form.serializeArray());
        var itemsToSubmit = hashDiff( startItems, currentItems);
    
        $.post($form.attr('action'), itemsToSubmit, etc.
      }
    });
    

    Then, all you have to write is the hashDiff function, which is straightforward and generally useful.

    This is nice because it can easily be packaged into a plugin, and it can work repeatedly on the same form if you’re using Ajax.

    function hashDiff(h1, h2) {
      var d = {};
      for (k in h2) {
        if (h1[k] !== h2[k]) d[k] = h2[k];
      }
      return d;
    }
    
    function convertSerializedArrayToHash(a) { 
      var r = {}; 
      for (var i = 0;i<a.length;i++) { 
        r[a[i].name] = a[i].value;
      }
      return r;
    }
    

    Here’s a minimal test:

      describe('hashDiff()', function() {
        it('should return {} for empty hash',function() {
          expect(hashDiff({},{})).toEqual({});
        });
        it('should return {} for equivalent hashes',function() {
          expect(hashDiff({a:1,b:2,c:3},{a:1,b:2,c:3})).toEqual({});
        });
        it('should return {} for empty hash',function() {
          expect(hashDiff({a:1,b:2,c:3},{a:1,b:3,c:3})).toEqual({b:3});
        });
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.