Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:18:07+00:00 2026-06-11T04:18:07+00:00

There is a string that is being formulated something like this Item:ShortName:Tax and if

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:18:08+00:00Added an answer on June 11, 2026 at 4:18 am

    You are missing some { and ( as well as a typo. The console log tells you all this!

    $(document).ready(function () {
    
        var list = "Item:ShortName:Tax_Item2:ShortName2:Tax2_Item3:ShortName3:Tax3_Item4:ShortName4:Tax4";
        var arg = 'Item2';
        findItem(arg);
    
        function findItem(argument) {
            $.each(list.split('_'), function () {
                if (this.split(':')[0] == arg) {
                    alert('Item found!');
                }
            });
    }
    
    }​);​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to know is there a string hashing function that would produce identical
This is an example of the string that's being worked with: xxxxxx[xxxxxx][7][xxxxxx][9][xxxxxx] I'm having
I have a string array that is being filled dynamically.... I would like to
I'm trying to group the following string into three groups. 0:0:Awesome:awesome That being "
str_replace('Ê','',$line); Ain't working. Is there some special string that represents that?
Is there a PHP string function that transforms a multi-line string into a single-line
I have a string that i need to split where there are 2 or
Is there a way to refer to a Javascript variable with a string that
Is there a way to mark a string such that it will not trigger
I am creating a base64 string. There is also '+' sign in that string.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.