0

ひょっとして、私がどうやって行くのか知っている人はいますか:

var guests = [];
for (var i = 0; i < parseInt(apartments) ; i++) {
     var pos = i + 1;

     var adults, children, infants;

     adults = $("#adults" + pos).val();
     infants = $("#infants" + pos).val();
     children = $("#children" + pos).val();
     guests.push({ Leg: pos, Adults: adults,
        Children: children, Infants: infants 
     });
}

これに:

Guests: [{ Leg: "1", Adults: "2", Children: "0", Infants: "2" },{ Leg:
"2", Adults: "2", Children: "1", Infants: "0" }]
4

1 に答える 1

0

使用する

JSON.stringify(guests);

そうすべきだと思います。

于 2013-01-25T16:38:36.400 に答える