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 6852987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:27:26+00:00 2026-05-27T01:27:26+00:00

I am making a music list with JSON for a search And displaying it

  • 0

I am making a music list with JSON for a search And displaying it as soon as the user enters some text. Here it is:

var music = [
{"name": "Abba"},
{"name": "Justin Bieber"},
{"name": "Taylor Swift"},
{"name": "David Guetta"},
{"name": "Usher"},
{"name": "LMFAO"},
{"name": "Enrique Iglesias"},
{"name": "Pitbull"},
{"name": "Eminem"},
{"name": "Nickelback"},
{"name": "Rihanna"},
{"name": "Queen"},
{"name": "Linkin Park"},
{"name": "Lady Gaga"},
{"name": "Gym Class Heroes"},
{"name": "Maroon 5"},
{"name": "heyhihello"},
{"name": "Paramore"},
{"name": "Owl City"},
{"name": "Black Eyed Peas"},
{"name": "Coldplay"},
{"name": "White Stripes"},
{"name": "Selena Gomez"},
{"name": "Selena Gomez and The Scene"},
{"name": "Creed"},
{"name": "Hinder"}

];
$(document).ready(function(){
sendm = function(txt){
var st = txt.toLowerCase();
if(st.length>0){
var res = new Array();
$.each(music, function(i, item) {
    if(item.name.substring(0, st.length).toLowerCase()===st){
       res[i] = item.name;
    }
});
document.getElementById("main-p").innerHTML = res.join("<br>");
}
};
});

Now if the user enters “Usher”, in the result, it will leave a few lines because of the
tags. How do I remove them?

  • 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-05-27T01:27:27+00:00Added an answer on May 27, 2026 at 1:27 am

    Change:

    res[i] = item.name;
    

    To:

    res.push(item.name);
    

    Then your array’s length will be the number of matches found instead of the index of the last match found.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a Music player for my web app. After user upload some
I am making a music player and I have a list with all the
this is my JSON [{id:23,name:Video Clips},{id:15,name:Deleted Scenes},{id:9,name:Music Albums},{id:7,name:Trailers},{id:18,name:Short Films},{id:21,name:Movie Clips},{id:1,name:Movies },{id:4,name:Plays},{id:22,name:Scenes},{id:2,name:TV Show},{id:5,name:Kids},{id:16,name:Interviews},{id:11,name:Film Songs},{id:14,name:Making of
I am making a music player in PyQt4, and I am using Phonon to
I'm making a little music app. I`m trying to make my layout as flexible
I am making an App in which i have to play music from iPod
I'm making a sound for the iPhone and I'm interested in adding background music
I'm making a game. Now if my player goes to another level the music
Making a drop down list for my JSP and the values I'm entering won't
I have a list of extension to mimetype in a INI file. However some

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.