2 Replies Latest reply on Jun 10, 2013 2:59 PM by TimSPQR

    Placing variables from db table in div vs form input fields

    TimSPQR Level 1

      Hello,

       

      Because of all the help I've received on this forum, I'm getting comfortable with reading data from db tables and writing back to them.

       

      Recently I've needed to create an "update" of a form (no refresh) where

      1 -  the data are read in from a table to a form

      2 -  the form data are changed by the user, and

      3 - the data are written back to the table.

       

      To do this, I've learned about parsing and displaying returned json data from a "success" under ajax.

      Here's a "mini" example of what I've learned:

      ...

              success: function(result)

        {

              $('#loadmehere1').html(result['localid']);

      ...

             $('#inload1').val(result['localid']);

              },

             error : function() { alert("error"); }

      });//End of ajax call

       

      So with my experimentation, I've found that ".html" is used to fill a div, and you have to use the ".val" to fill an input box on a form.

       

      My questions are:

      1. Can you point me in the right direction to learn about why an input statment needs a ".val" and a div can take an ".html"?

      2. Would you populate divs and input statements with different commands?

       

      Thanks very much!