javascript - jquery, append multiple values to one input hidden -
i have following variable
var $pk3s_c = $('<input id = query_form_tbl_info_'+query_index +'_pk3ss[] name =query_form[tbl_info]['+query_index+'][pk3ss][] type = hidden></input>');
and array
var pk3s = opts[tbl]["cols"];
during iteration through array, want append elements of array $pk3s_c
$.each(pk3s, function(i,pk3){ $pk3s_c.attr('value',pk3); })
the code above not working, shows me have appended last element of pk3s, , not of them. how can append each element of p3ks hidden input?
you aren't going array string field without converting string.
the json format very useful this
// convert array string var mystring = json.stringify(myarray); // put string field it's value $('input').val(mystring);
javascript can interpret resulting string , server side languages can convert string array value can understand (see php, ruby)
Comments
Post a Comment