javascript - dynamically added input text field and get values to php and send to mysql -
i have created attachment , have problem develop. text boxes in bottom dynamically created when add article button pressed , want update "added article details" section insert mysql database times have 5 rows sometime 2 rows , 1 row wants add. named text box 1,2,3,4,5,6....... how solve my javascript
function added_artic() { if (added_art) { document.getelementbyid('added_article').style.csstext = "display:block;"; var art_name = document.getelementsbyname('article_name')[0].value; var app = document.getelementsbyname('appearance')[0].value; var weight = document.getelementsbyname('weight')[0].value; var netweight = document.getelementsbyname('net_weight')[0].value; var qty = document.getelementsbyname('qty')[0].value; var test = document.getelementsbyname('test')[0].selectedoptions[0].text; var added = document.getelementbyid("added"); var i_artname = document.createelement('input'); i_artname.value = art_name; i_artname.name = "art_name" + art_name_id++; i_artname.id = "txt_added"; i_artname.disabled = true; added.appendchild(i_artname); var i_app = document.createelement('input'); i_app.value = app; i_app.name = "app" + app_id++; i_app.id = "txt_added"; i_app.disabled = true; added.appendchild(i_app); var i_weight = document.createelement('input'); i_weight.value = weight; i_weight.name = "weight" + weight_id++; i_weight.id = "txt_added"; i_weight.classname = "cal_weight"; i_weight.disabled = true; added.appendchild(i_weight); var i_netweight = document.createelement('input'); i_netweight.value = netweight; i_netweight.name = "netweight" + netweight_id++; i_netweight.id = "txt_added"; i_netweight.classname = "cal_netweight"; i_netweight.disabled = true; added.appendchild(i_netweight); var i_qty = document.createelement('input'); i_qty.value = qty; i_qty.name = "qty" + qty_id++; i_qty.id = "txt_added"; i_qty.classname = "cal_qty"; i_qty.disabled = true; added.appendchild(i_qty); var i_test = document.createelement('input'); i_test.value = test; i_test.name = "test" + test_id++; i_test.id = "txt_added"; i_test.classname = "cal_test"; i_test.disabled = true; added.appendchild(i_test); var remove_btn = document.createelement('input'); remove_btn.type = "button"; remove_btn.value = ""; remove_btn.id = "remove_btn"; remove_btn.onclick = function () { i_artname.parentelement.removechild(i_artname); i_app.parentelement.removechild(i_app); i_weight.parentelement.removechild(i_weight); i_netweight.parentelement.removechild(i_netweight); i_qty.parentelement.removechild(i_qty); i_test.parentelement.removechild(i_test); edit_btn.parentelement.removechild(edit_btn); this.parentelement.removechild(this); get_total(); if (!document.getelementsbyname("test1")[0] && !document.getelementsbyname("test2")[0] && !document.getelementsbyname("test3")[0] && !document.getelementsbyname("test4")[0] && !document.getelementsbyname("test5")[0] && !document.getelementsbyname("test6")[0] && !document.getelementsbyname("test7")[0] && !document.getelementsbyname("test8")[0] && !document.getelementsbyname("test9")[0] && !document.getelementsbyname("test10")[0]) { document.getelementbyid('added_article').style.csstext = "display:none;"; } } added.appendchild(remove_btn); var edit_btn = document.createelement('input'); edit_btn.type = "button"; edit_btn.value = ""; edit_btn.id = "edit_btn"; var = 'weight' + (weight_id - 1); var b = 'netweight' + (netweight_id - 1); var c = 'qty' + (qty_id - 1); edit_btn.onclick = function () { document.getelementsbyname(a)[0].disabled = false; document.getelementsbyname(b)[0].disabled = false; document.getelementsbyname(c)[0].disabled = false; edit_btn.style.csstext = "background-image: url('images/update.png');"; edit_btn.onclick = function () { document.getelementsbyname(a)[0].disabled = true; document.getelementsbyname(b)[0].disabled = true; document.getelementsbyname(c)[0].disabled = true; edit_btn.style.csstext = "background-image: url('images/edit.png');"; get_total(); }; }; added.appendchild(edit_btn); document.getelementsbyname('article_name')[0].value = "article name"; document.getelementsbyname('appearance')[0].value = "appearance"; document.getelementsbyname('weight')[0].value = ""; document.getelementsbyname('net_weight')[0].value = ""; document.getelementsbyname('qty')[0].value = ""; document.getelementsbyname('test')[0].value = "select tested karatage type"; } }
my project screen shot -
Comments
Post a Comment