0

I have a form in which the data is made up of divs in a table like layout. Each row is considered a record but when I get the serializeArray values there doesn't seem a way to distinctly separate out each row. Below is a snippet of the div structure, then an example of serialized data returned. First the div structure.

<div id="mainnotetocodediv">
<div id="1">
    <input type="hidden" name="installnoteid" value="1">                         
    <label class="blockinline width-800"></label>
    <input type="text" name="ksinotecode" class="width-75" value="r">
</div> 
<div id="2">
    <input type="hidden" name="installnoteid" value="2"> 
    <label></label>
    <input type="text" name="ksinotecode" class="width-75" value="r">
</div> 
<div id="3">
    <input type="hidden" name="installnoteid" value="3">
    <label></label>
    <input type="text" name="ksinotecode" class="width-75" value="r">
</div> 
<div id="4">
    <input type="hidden" name="installnoteid" value="4">
    <label></label>
    <input type="text" name="ksinotecode" class="width-75" value="r">
</div>

Now here is the array returned in the console log. I structured how each row should logically layed out.

[{"name":"installnoteid","value":"1"},{"name":"ksinotecode","value":"r"}
,{"name":"installnoteid","value":"2"},{"name":"ksinotecode","value":"r"}
,{"name":"installnoteid","value":"3"},{"name":"ksinotecode","value":"r"}
,{"name":"installnoteid","value":"4"},{"name":"ksinotecode","value":"r"}]

What would be the best way to handle this?

user1554967
  • 121
  • 3
  • 11
  • The above data is the actual data in the console log. I just put the line breaks for each record for readability. – user1554967 Jan 17 '18 at 15:51

1 Answers1

0

make all the input name as array

like below i have added for one <div>

<div id="1">
    <input type="hidden" name="installnoteid['one'][]" value="1">                         
    <label class="blockinline width-800"></label>
    <input type="text" name="ksinotecode['one'][]" class="width-75" value="r">
</div> 
Arun Kumaresh
  • 6,211
  • 6
  • 32
  • 50