I'm trying to find the index of an array within an array, but I have forgotten some steps, and I'm not exactly sure if I require another loop.
I will start with an array that contains pushed values like so:
var payments = [["2015-03-10", "100.00"],["2015-03-11", "14.00"]];
When I click on a button with a similar value, I want to remove it from the array.
My buttons will have an onclick function, like so:
onclick="removePayment(this.value)"
The value of the buttons looks like this:
value="' + payments[i][0] + ': $' + payments[i][1] + '"
Which is basically the same as: 2015-03-10: $100.00
I will then (by passing the value as a parameter via onclick), re-create the way it appears as an array value, hoping that I can now capture its index within the "payments" array.
// We start with a string, like: "2015-03-10: $100.00"
var amt = val.split(':')[0]; // 100.00
var date = val.split('$')[1]; // 2015-03-10
var temp = (amt + ',' + date).split(','); // ["100.00", "2015-03-10"]
console.log(temp);
for (i = 0; i < payments.length; i += 1) {
console.log(payments[i].indexOf(temp)); // returns -1
}
Thanks in advance!