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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -