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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:41:54+00:00 2026-06-09T11:41:54+00:00

Hi here I have a array variable links. I have to add the value

  • 0

Hi here I have a array variable links. I have to add the value for keywords and label dynamically. How do you add this? Thank you

update

MyIssue I need to add(push) the value for keyword and labels dynamically in that Array for autocomplete. How to do this?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>jQuery UI Autocomplete - Default functionality</title>
    <link rel="stylesheet" href="http://jqueryui.com/themes/base/jquery.ui.all.css">
     <script type="text/javascript" charset="utf-8" src="../js/cordova-1.7.0.js"></script>
 <script type="text/javascript" charset="utf-8" src="../js/jquery-1.7.2.js"></script>

    <script src="http://jqueryui.com/ui/jquery.ui.core.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.widget.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.position.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.autocomplete.js"></script>
    <link rel="stylesheet" href="http://jqueryui.com/demos/demos.css">
    <script>
    $(function() {
        var links = [
        {
            keywords: ['create', 'add', 'make', 'insert', 'user'],
            label: "Create user",
            //desc: "Create a user in the system",
            //url: 'http://mysite.com/user/create/'
        },
        {
            keywords: ['create', 'add', 'make', 'insert', 'organisation'],
            label: "Create organisation",
           // desc: "Create an organisation in the system",
           // url: 'http://mysite.com/organisation/create/'
        }];
        $( "#tags" ).autocomplete({

             source: function(request, response) {  
             var matched = [];

        for (var k = 0; k < links.length; k++) {
            if (checkSearchWordsMatchKeywords(request.term, links[k]['keywords'])) {
                matched.push(links[k]);
            }
        }
        // display the filtered results
        response(matched);

             } 
        });

        function checkSearchWordsMatchKeywords(searchWords, keywords)
        {
            var searchWords = searchWords.toLowerCase();    // Lowercase the search words
            var searchWords = searchWords.split(' ');       // Break up the search into separate words
            var numOfSearchWords = searchWords.length;      // Count number of search words
            var numOfKeywords = keywords.length;            // Count the number of keywords
            var matches = [];                               // Will contain the keywords that matched the search words

            // For each search word look up the keywords array to see if the search word partially matches the keyword
            for (var i = 0; i < numOfSearchWords; i++)
            {
                // For each keyword
                for (var j = 0; j < numOfKeywords; j++)
                {   
                    // Check search word is part of a keyword
                    if (keywords[j].indexOf(searchWords[i]) != -1)
                    {
                        // Found match, store match, then look for next search word
                        matches.push(keywords[j]);
                        break;
                    }
                }
            }
            if (matches.length == numOfSearchWords)
            {

                return true;
            }
            }

    });
    </script>
</head>
<body>

<div class="demo">

<div class="ui-widget">
    <label for="tags">Tags: </label>
    <input id="tags" />
</div>

</div><!-- End demo -->

</body>
</html>
  • 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-09T11:41:55+00:00Added an answer on June 9, 2026 at 11:41 am

    General way is (provided you know the index of keyword array),

    links[index].keywords[links[index].keywords.length] = "your new value";
    

    and

    links[index].label = "your new label value";
    

    Let us know how do you determine index value,so that we can help you in more specific way 🙂

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

Sidebar

Related Questions

I have this code right here, where the $friends variable is an array with
i have an array which could look like this: $config[$name][$array]['key'] = 'value'; // here
Noob question here! I have an array with hashes that looks like this: arr
I have this $data array: (built on a shell, not a form) (debugged here)
I have some problem to order an array by a field of this, here
What I need to happen is have the top5 variable array get used for
Here is my problem: I have an array of model class(Let's say, 'addressModel' with
I have an array but something goes wrong with it, here is my code
Here's an example of what I mean: I have an array: array('type'=>'text', 'class'=>'input', 'name'=>'username',
I have a multidimensional array, here: $noticeDate = json_encode( $noticesDates ); and I want

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.