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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:17:23+00:00 2026-05-20T23:17:23+00:00

I have an ASPX page that creates a Gridview. My JQuery function pulls values

  • 0

I have an ASPX page that creates a Gridview. My JQuery function pulls values from the Gridview data to populate my JQuery autocomplete source. All works fine with this. Now I want to have my autocomplete values go to a link when they are clicked. That link is also in the Gridview where I use text() to get the text value. (I search my Gridview for links containing “ModelDetail” and store the text to an array) Do I need a JQuery 2 dimensional array? If so, how can I do this? Here’s my code:

<script language="javascript" type="text/javascript">
    $(document).ready(function() {

        var modelnames = new Array();
        $('#ctl00_body_modellistGrid a[href*="ModelDetail"]').each(function() {
            modelnames.push($(this).text());
        })


        $("input#autocomplete").autocomplete({
            source: modelnames
        });

    });

</script>

Thanks in advance!
Bob

  • 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-20T23:17:24+00:00Added an answer on May 20, 2026 at 11:17 pm

    JavaScript handles arbitrary objects very nicely — use an object to store the text and the link.

    My JavaScript is a little rusty, but something like this should work:

    var models = [];
    $('#ctl00_body_modellistGrid a[href*="ModelDetail"]').each(function(i) {
        // Note that we're using the optional index parameter of the each function,
        // which I have called 'i'
        // We will create an object with a label and a value and store it in models[i]
        models[i] = { label: $(this).text(), value: $(this).attr("href") };
    });
    
    // We will now pass this array of objects to the autocomplete function
    // The autocomplete function, if given an array of objects, is expecting
    // two properties: 'label' and 'value'
    $("input#autocomplete").autocomplete({
        source: models,
        // We will also provide a function when the user selects an option
        select: function(event, ui) {
            // ui.item should hold the object we passed in, I think
            // Let's redirect the user to the url
            // ui.item.value should hold the url
            window.location.href = ui.item.value;
        }
    });
    

    I believe the above should work. I put a very basic demo on jsFiddle: –> http://jsfiddle.net/B3dgW/

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

Sidebar

Related Questions

No related questions found

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.