JavaScript - How to pass array from jquery to controller using hidden element only

Asked By Madhu krishna on 06-Jul-16 09:53 AM
 var jsdocids = [];
            $('input:checkbox:checked').each(function () {
                var isno = $.isNumeric($(this).val());
                if (isno == true) {
                    jsdocids = $(this).val();
                    alert(jsdocids);
                }
            });

i want to pass this jsdocids [] through hidden element and send it using html.begin form post..
   @using (Html.BeginForm("SaveQuestionData", "ExecutiveSummary", FormMethod.Post, new { Id = ViewBag.wizardID }))
    {
        <input type="hidden" id="hidocID" name="hidocID" value="jsdocids []" />

in controlller i am trying to access using form collection collection 

  string docIds = Convert.ToString(collection["jsdocids"]);  but i am getting null.. what am i missing here?
          
Aman Kedia replied to Madhu krishna on 03-Sep-16 09:32 AM
I guess, you are always assigning new value to the array. Check by using PUSH() method 
array.push(data);
Robbe Morris replied to Madhu krishna on 03-Sep-16 09:59 AM
Is there a reason you are not using AJAX and JSON to save your data?