There is a string that is being formulated something like this
Item:ShortName:Tax and if more items are added, it is appended to string like Item:ShortName:Tax_Item2:ShortName2:Tax2, adding one more, Item:ShortName:Tax_Item2:ShortName2:Tax2_Item3:ShortName3:Tax3 and so on. What I want to know is that, I have to check for if a item is present in the list, say, shirt, or jeans. It would be the first in array when separated by colon.
I used this.
var list = "Item:ShortName:Tax_Item2:ShortName2:Tax2_Item3:ShortName3:Tax3_Item4:ShortName4:Tax4";
$(document).ready(function () {
var arg = 'Item2';
findItem(arg);
fucntion findItem(argument) {
$.each(list.split('_'), function () {
if (this.split(':')[0] == arg) {
alert('Item found!');
}
};
};
But the alert doesn't appear, though Item2 is in the list.
In case its not clear, this list split by _ contains a array (as you can see) and each of that array separated by : contains Itemname, ItemShortName, TaxOnItem, now in all those small array, I have to check for first array that contains the ItemName to see if a particular item exists or not! How can I do this?