Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Best method for detecting field change on form for updating db tables.

6:01 pm on Mar 21, 2013 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0

hi all,

I'm looking the the best or better solution when testing for changed html form fields prior to sql table updates.

I have a html form that supplies data to multiple sql tables via PHP. I currently pass all form fields to my PHP script where i have "if" test blocks that tests all input fields for each table by comparing input and table fields. I realize this is not the best way to handle whether a table needs to be updated.

I hind site, it would have been better to test a boolean variable that represents the block of fields for each table in the form and either send only the form fields for that table to the PHP sql table update script. But i don't want to do a major rewrite to the html/javacsript/php code, so i'd settle for replacing the PHP "if" test blocks with a single boolean test variable for each table that is passed along with the data.

Upon some research, there seems to be a few methods floating around.

  • using html or javascript onchange events.
  • serialize the form before and after user submit then test.
  • Comparing default and current from field Values with JavaScript function.

    It seems that having to update all the forms to accommodate the onchange attribute and write a javascript function would be a lot of work.

    Serializing the form and comparing seems to be the easiest thing to do.

    Comparing default and current from field Values with JavaScript function seemslike a lot of work as well.

    I would appreciate your opinions.


    Join The Conversation

    Moderators and Top Contributors

    Hot Threads This Week

    Featured Threads

    Free SEO Tools

    Hire Expert Members