I have some script to read the values from html table but there is a problem to compare name of existing items in array with temporary item name.
$(document).ready(function () {
var selling = new Array();
$('table tr').each(function() {
var name = $(this).find('td:eq(1)').html();
var price = $(this).find('td:eq(3)').html();
var amount = 1;
var item = new Array(name,price,amount);
var found = 0; //selling.find(name)? notworking :)
if(found.length > 0) {
alert('found'); //get amount and change it
} else {
selling.push(item); //push new item to array
}
});
alert(selling);
});
I want to get an array
[cat, 10$, 150]
[cow, 120$, 7]
[bird, 500$, 1]
[horse, 400$, 2]
Can somebody tell me how to compare those names? or do this better way?