php - jQuery updated values not getting new value -
i want make table inline editable through jquery. when press edit button table row become editable previous values showed in text fields. when enter new values , press save button not updated values , database remain unchanged.
code previous values show in editable table row is:
var nam =$("#name_"+id).html();
code make table row editable is:
$("#name_"+id).html("<input type='text' name='name' id='name_"+id+"' value='"+nam+"'>");
code updated values:
var nm = $('#name_'+id+'').text();
ajax request update database:
url: "inlineupdate.php?id="+id+"name="+nm,
point #1:: id correction
"name_"+id
pointing 2 elements @ same time, <input>
, table row contains <input>
. input
id, instead of using "name_"+id
twice, must use other id. eg. "name_"+id+"_editable"
, use update value.
point #2:: update value
var nm = $('#name_'+id+'_editable').val();
here,as <input>
field, need use .val()
, not .text()
;
point #3:: ajax parameter passing
url: "inlineupdate.php?id="+id+"name="+nm,
to
url: "inlineupdate.php?id="+id+"&name="+nm,
^----------- missed (&)
Comments
Post a Comment