Wednesday, 24 October 2018

javascript - Add elements to 2D array in jquery


Possible Duplicate:
How to create a two dimensional array in JavaScript?






I want to push elements to 2D array,



My code is,




        var results = [];
var resultstemp = [];
function bindlinks(aamt,id1) {
resultstemp=results;
imagesArray.push($("#image1").mapster("get"));

if(results.length==0)
{
results.push([id1]);

}
else
{
var ck=0;
var lng=results.length;
for (var i = 0; i < lng; i++) {

if(results[i]==id1)
{


ck=1;
results = jQuery.grep(results, function(value) {
return value != id1;
});

}
}
if(ck==0)
{
results.push(id1);

}
}


I want to push id as well as aamt to array. Here i am pushing only id to array. I am not sure about how to add aamt to second position in 2D array.



Help me please,



Thank you

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...