jquery form creation and submit multiple parameters aren't arriving at controller -
i have checkboxes , i'm getting values them with:
var itemids = []; $('input:checkbox.itemcheckbox:checked').each(function () { itemids.push($(this).val()); });
then i'm taking these values , create form:
var form = $('<form/>', { action: '@url.action("process", "items")', method: 'get', css: { display: 'none' }, html: $('<input type="hidden" name="itemids" value="' + itemids + '"/>') }); $('body').append(form); form.submit();
on submitting form method on controller is:
[httpget] public filestreamresult movetofinanceprocessing(ilist<int> itemids) { ... }
so reason i've implemented things way because i'm trying download zip file , way work.
the problem works 1 checkbox checked. can't work multiple item ids.
i know problem line:
html: $('<input type="hidden" name="itemids" value="' + itemids + '"/>')
i can manually multiple parameters go method going:
html: $('<input type="hidden" name="itemids[0]" value="3"/><input type="hidden" name="itemids[1]" value="4"/>')
the trouble can't them html line itemids variable this.
can please tell me how implement this?
i think should try this
html: $('<input type="hidden" name="itemids[]" value="' + itemids + '"/>')
so in controller array.
Comments
Post a Comment