Welcome to WebmasterWorld Guest from 54.145.104.199

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)

5+ Year Member



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.

    thanks.
  •  

    Featured Threads

    Hot Threads This Week

    Hot Threads This Month