mysql - Save dynamic data created using createElement(Javascript) to database -
i new forum webpage designing. trying design profile management tool using jsp in there dynamically added(through javascript createelement) input fields names assigned. able save 1 record database , others ignored. question how save data dynamically added? please me on this.
javascript code:using below function, able javascript array
function addedu() { $(document).ready(function(){ $(".ed").each(function(input){ var value = $(this).val(); var id = $(this).attr('id'); t= id+' : '+ value; arr.push(t); }); }); var newinput1 = document.createelement("input"); newinput1.name="i1" newinput1.classname="ed" newinput1.id="education" newinput1.innerhtml = ""; document.getelementbyid('edu').appendchild(newinput1); }
jsp code:
string edu1=request.getparameter("i1"); statement st1=con.createstatement(); string sql1="insert education values('"+pno+"','"+edu1+"'); st1.executeupdate(sql1);
on client side can use jquery dynamically add rows , read necessary values. access rows of table can use jquery selectors. save data in javascript array, convert json , send server side.
here example (with using php, in case doesn't matter):
on server side you'll need make lot of inserts via plain jdbc, use batch insert instead of hitting database once each insert statement.
here example:
if you'll decide use spring, here example:
Comments
Post a Comment