Click here to Skip to main content
15,566,625 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a perfectly working code for auto populate textbox via rest api(it populates after 2 characters typed). Can you assist me on modifying the same api code to find out the total length of array(/total companies) and assign to textbox val something like $("#TotalCompany").val(...) I currently have autopopulate companies $("#Company").autocomplete working just fine.

$(document).ready(function () {
  var baseServiceUrl = '';
                     minLength: 2,
                     source: function (request, response) {
                      $.getJSON(baseServiceUrl + '/company/name/' + request.term + '/?callback=?',
                                   contextKey: function () {
                                  // applies to associated parties
                                 var key = $(this).parent().parent().find('.type').val();
                                 if (key !== "--Select--" && key !== "")
                                          key = key === "O" ? "Company" : "Company";
                                          key = "";
                                 return key;
                         format: "json"
                   function (data) {
                                     function (item) {
                                                               return {
                                                                               label: item['Company'].replace(/&/g, '&'),
                                                                               value: item['Company'].replace(/&/g, '&')


The web service API return something similar to the script below:

Please let me know if you need more details Greatly appreciated any help

What I have tried:

<ArrayOfCompany xmlns="" xmlns:i=>
Updated 20-Aug-20 19:28pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900