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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:46:03+00:00 2026-05-21T03:46:03+00:00

I spent a lot of time, to add additional parameters to the Jquery-Autocomplete-Source. But

  • 0

I spent a lot of time, to add additional parameters to the Jquery-Autocomplete-Source. But I can’t get it finished.

What I’m trying to do: I have an autocomplete form with a jQuery datasource. If you select something from the autocomplete, it will be inserted into a table (text and a hidden field with the id) and the function lesen is started (works fine). Function lesen reads the value of every element with the “class” nutzerid (the hidden field) to an array and puts it to an input field – the input field is the collector for all ids(works!). BUT! The autocomplete should read the value of this field an send it as a parameter to my JSON source. But it doesn’t. The Firebug console shows an empty parameter. Even though an alert is able to show the value. I really don’t know, what I’m doing wrong.

I also tried to replace the input field (collector of all ids) by a variable. But the same problem occurs here. I can alert the value of the var. But trying to attach it to the source produces an empty param. I also tried to give the value to autocomplete via param, extraparams option. No success. I think there is a problem with joining the array. Maybe the step in lesen where all ids are pushed to an array and the array is filled into the form. But I’m out of ideas how to solve this.

Why i’m doing this? I want the JSON source PHP to exclude the already selected ids in its MySQL query. What has been selected one the previous requests should not be displayed with autocomplete anymore. So I have to post, what was added to the requesting page before. And this is the way (probably not the cleanest) I’ve chosen. Imagine a shopping cart. If a product is attached to the shopping cart, it should not be displayed in future requests. Of course I’m open to new approaches.

<input type="text" id="ausschluss" />    
$(document).ready(
function() {



//this functions reads every hidden field (form the added items) an puts the array as string to a hidden field      
function lesen(){
            var itemsarray = [];
          $(".nutzerid").each(function () {
           var items = $(this).attr('value');
           itemsarray.push(items);
          });
          $( "#ausschluss" ).val(itemsarray);

          };


    //this function attaches the selection (from the autocomplete) to a table it creates text, a hidden field with the user id and a button
        function log( name, id ) {
            $("<tr> <td>"  + name + "<input class='Entf' type='button' value ='Entfernen' />" + "<input type='hidden' class='nutzerid' name='hiddenField' value='" + id + "' /></td></tr>").appendTo("#log");
            $( "#log" ).attr( "scrollTop", 0 );
            lesen();

                   }
//this is the autocompletepart
        $( "#REMOTE" ).autocomplete({
            source: "json.php?aus=" + $( "#ausschluss" ).val(), //this is not working. the firebug console shows an empty param (.php?aus=&term=blabla
            minLength: 2,
            select: function( event, ui ) {
                log(ui.item.value,ui.item.id);          
                alert($( "#ausschluss" ).val());  //this works! after selecting an item from the autocomplete it shows me the value of the field "ausschluss", like it should be appended to the source
                }

        });

//this one captures the click of a button. identified by the class and kills the <tr> <td> and all elemtns in it        
$('.Entf').live('click',function(event){
     $(this).parent().parent().remove();
     lesen();
   });




});
  • 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-21T03:46:04+00:00Added an answer on May 21, 2026 at 3:46 am

    The jQueryUI autocomplete control – much like the dialog – is created using the $('#myElement').autocomplete() initialiser.

    Your problem is happening because you are initialising the autocomplete once using $('#ausschluss').val(), which hasn’t been populated yet. The autocomplete will not refer back to that value again – it is effectively cached. You need to refactor your code to pass the ausschluss to a function as a variable, and have that function then call autocomplete or (probably better), try to set the source on the fly like so:

    $( "#REMOTE" ).autocomplete( "option", "source", 'json.php?aus=' + $('#ausschluss').val() );
    

    You’d call this whenever your ausschluss value changed.

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

Sidebar

Related Questions

I have struggled a lot spent quiet a lot of time but unable to
I have spent a lot of time looking for a solution, but could not
I've spent a lot of time googling this and testing in my program, but
I've spent a lot of time trying to figure out what the each line
I am currently making an Android launcher and have spent a lot of time
I already spent a lot of time trying to solve this problem, I've seen
I've spent a lot of time with this problem. I have custom user control
I spent a lot of time to find a solution to this problem but
I have spent lot of time doing research on VIM. I am Windows guy
I spent a lot of time figuring out the function in the code level

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.