-1
votes
0answers
16 views

Shortest Path 2d array javascript

Hello so i am trying to come up with a 2d shortest path algorithm using Dijkstra's shortest path algorithm. I understand the concept of the algorithm we are using a breadth first search. I believe my ...
0
votes
1answer
15 views

JavaScript 2D array unable to retreive element in IE

I have the following JavaScript code that executes fine in Firefox, but in Internet Explorer 9 generates the error message: SCRIPT5007: Unable to get value of the property '2': object is null or ...
0
votes
2answers
22 views

Concisely mapping 2 columns from 2D array to key:value pairs

In this example snippet of code, I selectively convert 2 columns from my 2D array into an object. The 1st column represents the keys, the 2nd represents the values. I feel like there is a more ...
0
votes
0answers
20 views

How do I eliminate empty records?

So I figured out how to create a script for a timesheet, but when my employees and I use it, we have a bunch of empty records on the target file. The source timesheet is: ...
0
votes
0answers
27 views

How do I generate an HTML table from 2D JavaScript array using a double for loop?

This is a multiplication table. I just need to figure out how to put each individual number into a different cell in a table. I need the corresponding numbers to line up. I have a div called dTable. ...
0
votes
0answers
43 views

JavaScript: 2-D Array in a game

I'm trying to make a two dimensional array for a zork like game, using javascript, that will change the location of the player based on what they input. The HTML just contains a picture and a ...
0
votes
1answer
36 views

2D JS Array assigning value for each index

This will be a stupid question. but why doesn't the following code assign 55 32 times to every corressponding index for j and k? var array= new Array([]); var rows=8; var cols=4; for (var j=0; ...
2
votes
1answer
56 views

Javascript 2D Array literate through 1 Dimension dosn't work

I've found some really useful guides on this site so i hope you can help me even further What am i doing? I have a exel based Product list saved as .txt i load this into javascript as follows: ...
2
votes
1answer
80 views

Dynamically add elements to 2-D array

I would like to know how to create an array, and add elements to it with a nested for-loop. How do I declare the array? I want the finished array to look like this: var array2d = { [0, 1, 2, 3], [0, ...
2
votes
3answers
116 views

How can I make this recursive?

Including the declaration of the 2d Array, how can I make the following recursive? I would like it to iterate until there are no "children()". self.buildRelationships = function () { ...
0
votes
1answer
28 views

Inconsistency with 2D array and for loop in Javascript

The following code results in the console printing "Z". <script> var x = new Array(new Array()); x[0][0] = "Z"; console.log(x[0][0]); </script> But if I replace x[0][0] = "Z" with a ...
0
votes
2answers
100 views

Best autocomplete for huge amount of select options from a 2d array?

For fields where are no more than thousand options available drop down lists seem to make the job. However, I have two arrays that flirt around dozens of thousands, so putting them to a comboboxes ...
0
votes
1answer
227 views

How to store an Object containing Array-Objects in local Storage By JSON

I have this Object containing pretty much anything i want to know about a workout. Yet when I Stringify the object the array-objects aren't stored or something. This is my object i want to stringify: ...
0
votes
1answer
100 views

How to delete a specific element from array? with String Index

How to remove/delete a specific element from an array with as index a string instead of numbers? this is my code: workout.program = new Array(); workout.program["first"] = new Array(); ...
0
votes
1answer
85 views

javascript 2D array iteration returning undefined function args

I am going through an exercise to recreate Conway's Game of Life and I have a basic strategy and I'm still very much in the "making it work" stage, so I know this looks pretty funny. The problem I'm ...
1
vote
2answers
144 views

Can't get value from javascript array using variable in brackets

function swapProd() { var image = document.getElementById("prodImage"); var dropd = document.getElementById("prodDrop"); image.src = "images/ej/" + prodArrJS[dropd.value][2] + ".jpg"; } the function ...
1
vote
1answer
114 views

Select a 2D array from a 2D array in javascript

I would like to select a piece of a 2D array from a large 2D array, I know how to do this using for loops but I was wondering if there is a more effective way of achieving this. Example: ...
0
votes
1answer
81 views

How do I subset a 2-dimensional array in Javascript?

I have been looking around, and seen that it is possible to retrieve an element from a two dimensional array with something like myArray[x][y]. However what I am looking to do take everything but the ...
0
votes
0answers
111 views

Map ajax response data to google line chart

I'm using the following code to create a line chart using the google charts api. var array = []; ajaxPost(action, "getData", params, function(data) { var response = ...
0
votes
1answer
36 views

Duplicating element in 2D Javascript Array

I have a loop which runs for the length of a 2D-Array. I need a way to duplicate one of the sub-arrays (the one loop is on) and add it to the end of the main array (making the loop go through that ...
0
votes
2answers
248 views

Convert C# 2D array (object [,]) to javascript 2D array

I am writing an APS.NET MVC application that reads data from DB and presents it with google charts. I am reading the data from DB in C# into 2D array and need to pass it to my javascript code that ...
0
votes
1answer
118 views

Javascript - sort without sort

Problem in Javascript I previously asked this question Javascript 2D array sorting - by numerical value with a solution provided using the sort function, which I have tried to use without sucsess. ...
0
votes
1answer
1k views

Javascript 2D array sorting - by numerical value

I've seen another couple of posts similar to this question, but none work for my scenario and at a lost how to solve this (such as Sort a 2D array by the second value) I will explain the problem - ...
0
votes
3answers
2k views

JavaScript Multi-Dimensional Array

I have a Student, who is in many courses, which have many Modules for each course. So far, I have got: var myStudent = new MySchool.Student("Bart", "Simpson", "0800 Reverse", "Some Street", ...
0
votes
4answers
239 views

Returning 2-dimensional array via C#

I'm getting content from a database and returning it for Ajax processing via Javascript. Pretty simple stuff. The issue here is that I can't seem to find a good way to loop through the data and the ...
0
votes
0answers
307 views

Js CSV to 2d array

Im going to parse CSV into JS matrix array, i want to get array[row][column] from CSV string. I know at first i need to parse csv into table, i dont want to use libs like jquery and etc. I think to ...
1
vote
3answers
15k views

Creating arrays in Javascript

I am little new to javascript and I am having alittle trouble wrapping my head around making a 2d (or maybe i might need a 3d) array in javascript. I currently have 2 pieces of information i need to ...
1
vote
6answers
474 views

Performing calculations on an Interger array in Javascript

I am trying add on dimension of an array together into a variable using a for loop. I have then using alert to show a pop up box with a value in it just to make sure it is working however the popup ...
4
votes
4answers
874 views

javascript array of arrays

I have the following arrays: var dates = new Array(); var answers = new Array(); Once Populated, they will be the same length. What I need is an array that pair the same index values of the arrays. ...
4
votes
3answers
4k views

“cannot read property 0 of undefined” in 2d array

Does anyone know why this gives an error? I've been trying at it way too long and I can't seem to figure it out. It errors with "cannot read property 0 of undefined", but it is clearly defined. (or so ...
2
votes
2answers
645 views

How to create a 2d array of zeroes in javascript?

Is there an easy way to programmatically create a 2d array in javascript? What I don't want: var array2D = [ [0,0,0], [0,0,0], [0,0,0] ]
1
vote
3answers
365 views

Javascript 2D array issue - all elements are a copy of the final entry

I'm creating a javascript 2D array from an XML file which I then manipulate and filter as necessary before displaying on the page. As I loop through the XML records, I manipulate the data a little, ...
2
votes
1answer
3k views

Traverse 2D Array (Matrix) Diagonally

So I found this thread that was extremely helpful in traversing an array diagonally. I'm stuck though on mirroring it. For example: var m = 3; var n = 4; var a = new Array(); var b = 0; for(var i = ...
1
vote
3answers
4k views

Javascript 2D array

I am trying to use 2 dimensional array in javascript for storing strings. But I am not able to get the values correctly. Below is my code. var commentstore=new Array(); function ...
2
votes
2answers
3k views

Jquery atrr + 2D array issue

i have the following script and i can't find out how to use the value inside car[0]['img'] inside this $('#img2').attr('src',car[0]['img']); im a JS noob so please explain me .. why jquery wont ...
249
votes
13answers
340k views

How can I create a two dimensional array in JavaScript?

I have been reading online and some places say it isn't possible, some say it is and then give an example and others refute the example, etc. How do I declare a 2 dimensional array in JavaScript? ...
7
votes
3answers
14k views

2D Javascript array

Simply put, is there a way to create a 2D javascript array using similar syntax to this? var newArray = [ [0, 1, 2], [3, 4, 5], [6, 7, 8] ]