How to post value by javascript/ajax after added elements by dynamicly -
i had success added elements dynamicly javascript using in form new lines.
the question how can post values new added lines?
added lines successed:
var form = '<tr id="package_' + data.custom +'">'; form += '<td><input type="text" class="form-control" name="donate[package_name]" id="package_name_'+ data.custom +'" value="" /> </td>'; form += '<td>'; form += '<select name="settings[currency]" id="currency_'+ data.custom +'" >'; form += '<option value="eur" selected="selected">eur</option> '; form += '<option value="usd">usd</option>'; form += '</select>'; form += '</td>'; form += '<td><input type="text" class="form-control" name="donate[money]" id="money_'+ data.custom +'" value="" /></td>'; form += '<td><input type="text" class="form-control" name="donate[price]" id="price_'+ data.custom +'" value="" /></td>'; form += '<td>'; form += '<select name="settings[pricetype]" id="pricetype_'+ data.custom +'" >'; form += '<option value="credits" selected="selected">credits</option>'; form += '<option value="wcoin" >wcoin</option> '; form += '</select> '; form += '</td>'; form += '<td>'; form += '<select name="settings[status]" id="status_'+ data.custom +'" >'; form += '<option value="1" selected="selected">on</option> '; form += '<option value="1" >off</option> '; form += '</select> '; form += '</td>'; form += '<td><a href="#" class="bg-green" id="save_'+ data.custom +'">save</a> / <a href="#" class="bg-red" id="remove_'+ data.custom +'">remove</a></td></tr>'; $('#paypal_packages_table').append( form );
my ajax post :
save_paypal_package: function (unique_id) { var package_name = $('#package_name_'+unique_id).val(); var currency = $('#currency_'+unique_id).val(); var money = $('#money_'+unique_id).val(); var price = $('#price_'+unique_id).val(); var pricetype = $('#pricetype_'+unique_id).val(); var status = $('#status_'+unique_id).val(); $.ajax({ type: 'post', url: muonlinewebs.base_url + 'admin-cp/save_paypal_package', data: {'type': 'save_paypal_package', unique_id : unique_id, package_name : package_name, currency:currency,money:money,price:price,pricetype:pricetype,status:status}, datatype: 'json', beforesend: function () { app.display_loader(); }, complete: function () { app.hide_loader(); }, success: function (data) { if(data.session) { app.notifier_box(data.response, data.type, data.error); settimeout(function () { location.href = muonlinewebs.base_url + 'logged-in'; }, 3000); } else { if (data.error) { app.notifier_box(data.response, data.type, data.error); } else { app.notifier_box(data.response, data.type, data.success); } } } }); }
step 1 : loaded page -> https://snag.gy/drzaq4.jpg step 2 : add new line -> https://snag.gy/xhkjsn.jpg
i can post values current packages loaded page. dynamicly added new lines returns nothing. ideas?
thanks in advance
you seem have naming scheme each element id. why not
document.getelementbyid(// id).value;
?
Comments
Post a Comment