homepage Welcome to WebmasterWorld Guest from 54.205.241.107
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

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

5+ Year Member



 
Msg#: 4557175 posted 6:01 pm on Mar 21, 2013 (gmt 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.

    thanks.

  •  

    Global Options:
     top home search open messages active posts  
     

    Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
    rss feed

    All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
    Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
    WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
    © Webmaster World 1996-2014 all rights reserved