My Jquery code
var attrid = [];
var attrvalue = [];
$.each($(".attname1"), function(index){
if($('.getval'+index+'').val() != undefined){
attrid.push($('.getval'+index+'').attr("id"));
attrvalue.push($('.getval'+index+'').val());
}
});
//outcome data
["5931", "5950", "5951", "5952"] //id
["cas", "bsd", "Canvas", "Grey"] //name
The result format that I actually want:
$ary = array (
[0] => array(
Id => 5931,
value=> cas,
),
[1] => array(
Id => 5950,
value=> bsd,
),
[2] => array(
Id => 5951,
value=> Canvas,
),
[3] => array(
Id => 5952,
value=> Grey,
)
);
Question:
Above code are using Jquery to loop the data and store into array, I'm trying to create loop to create the result format the I want, but I failed to do that,anyone can provide me some sample code or idea which is can using Jquery to create the results format that I provided.Thank you.