.NETLearner 0 Newbie Poster


Im trying to save a change value to the database from an autocomplete textbox.
I have 2 scenarios
1) Add a new value without selecting any option from the autocomplete list. I want the oblur or any similar method of the textbox to hit whenit loses focus to call a method that calls a controller method and saves to the database.
2) Select from the list of options from the autocomplete list and be saved to the db.
The textbox Im using is a created dynamically. THe value to it is set on lost focus and the textbox disappears.

The issue im facing is that either of the method works, either select item from thelist or the hand written value. This is because i have written my code the following way
1) Call a method that makes a ajax call to save to the db in the select option of the autocomplete. THis doesnt handle the handwritten value for some reason.
2) If i use Onblur method and also have the select - autocomplete option, theo nblur / change works but the selection by mouse click on the options of the autocomplete doesnt work

            var fieldValue;
            if (parent.children('input').length == 0) {
             var inputtxtbox = "<input type='text' style='min-width:18em;width:100%' class='inputtxtbox' value=\"" + parent.text() + "\">";

                   source: data,
                   select: function (event, ui) {
                       Common.Server.UpdateLabel('@Id', parent.closest('tr').attr('id'), ui.item.value);                  
            $("input.inputtxtbox").blur(function () {      
         var txtboxValue = $(".inputtxtbox").val();
         Common.Server.UpdateLabel('@Id', target.closest('tr').attr('id'), txtboxValue);

Any help is appreciated? IS there a better way to achieve this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.