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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:59:13+00:00 2026-05-26T18:59:13+00:00

I have a JQuery suggest box using a key and a value. The key

  • 0

I have a JQuery suggest box using a key and a value. The key is the saved value, for example a userId and the value is the shown value such as a username.

When having a blank field it works great. I type a few characters, select a name and the value is added as the value that is posted with the HTTP request. Now, how should I prefill a form’s suggest with when it already has a value. When placing the saved userId as the value the suggest shows the userId but, obviously I want to show the username. I also tried to echo the username that was selected but than, if the username is not changed the posted value will be the username.

                <script>
                <!--
                $(document).ready(function() {
                    $("#creatorUserId").autocomplete("Gateway.php?action=UserAction&subAction=suggest",{
                        parse: function(data) {
                            var parsed = [];
                            data = data.data;

                            for (var i = 0; i < data.length; i++) {
                                parsed[parsed.length] = {
                                    data: data[i],
                                    value: data[i].key,
                                    result: data[i].value
                                };
                            }

                            return parsed;
                        },
                        formatItem:function(item, index, total, query){
                            return item.value;
                        },
                        formatResult:function(item){
                            return item.id;
                        },
                        dataType: 'json'
                    });
                });
                -->
                </script>   

<input type="text" name="creatorUserId" id="creatorUserId" value="3" size="40" />

How could I solve 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-05-26T18:59:14+00:00Added an answer on May 26, 2026 at 6:59 pm

    Try this

    <script>
                <!--
                $(document).ready(function() {
                    $("#creatorUserId").autocomplete("Gateway.php?action=UserAction&subAction=suggest",{
                        parse: function(data) {
                            var parsed = [];
                            data = data.data;
    
                            for (var i = 0; i < data.length; i++) {
                                parsed[parsed.length] = {
                                    data: data[i],
                                    key: data[i].key,
                                    value: data[i].value
                                };
                            }
    
                            return parsed;
                        },
                        formatItem:function(item, index, total, query){
                            return item.value;
                        },
                        formatResult:function(item){
                            return item.id;
                        },
                        dataType: 'json'
                    });
                });
                -->
                </script>   
    

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

Sidebar

Related Questions

I have a jQuery text box autocomplete script which uses a PHP script to
Could you suggest any word counter in jquery which doesn't have maxcount option ?
I am using jQuery Mobile and have few pages in one HTML page. When
I am working on Project where I have JQuery 1-Page Horizontal scrolling website using
I am using JQuery. I have below JQuery Code which working fine in Firefox,
I have a problem displaying the autosuggest box inside a jQuery dialog. The auto
I am having a Search text-box for which I have to implement a search
I have a site that is using jQuery UI to display forms located on
I have a text box that is wired to JQuery UI Autocomplete. As the
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody

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.