get textbox id and value from serialize() jQuery -
it possible textbox id , value serialize()
form using jquery?
i have code:
var datastring = jquery('#form_name').serializearray(); var id = ''; txtcalrev_list = ''; jquery.each(datastring, function(i, field){ id = field.attr('id'); txtcalrev_list = txtcalrev_list + (field.value + "_" + id + ","); }); alert(txtcalrev_list); // values
all suggestions welcome , appreciated, thanks.
i'm not sure version of jquery you're using, if you're wanting comma delimited string entries in format [value]_[id], try code:
var datastring = $('#form_name').serializearray(); txtcalrev_list = ''; $.each(datastring, function (i, field) { if (field.name.indexof('txt') == 0) txtcalrev_list = txtcalrev_list + (field.value + "_" + field.name + ","); }); alert(txtcalrev_list);
try approaching using name property. weed out other objects not prefixed 'txt', can omit if want.
Comments
Post a Comment