Monday, February 27, 2017

sending multiple inputs on ajax

i have a form where i get a collection of records, and after being present is shown like this:

  <input name="position" id="nameText" step-id="3" type="number" value="1" class="form-control stepinput">

<input name="position" id="nameText" step-id="4" type="number" value="2" class="form-control stepinput">

<input name="position" id="nameText" step-id="5" type="number" value="3" class="form-control stepinput">

The value is to later sort the records, and the "step_id" attribute is to send via ajax to update the specific record, but my data is not quite looking good. Wich is the best way to send my data to the controller to later being updated the records

My current code:

$('button.update-positions').on('click', function(event){
            event.preventDefault();
            var form = $(this).closest(".steps-form");

            var map = {};
            $(".stepinput").each(function() {

                map[$(this).attr("step-id")] = $(this).val()

            });

        })




via Pedro

Advertisement