locked
Textbox transform in Select Dropdown based on closest div when function onchanged trigger at one of the field; option failed populated RRS feed

  • Question

  • User-893002196 posted

    Hi All,

    The textbox name: q able to transform become select field when some function trigger. But, I failed to populate the option into the new select field. How can I do that?

    Something wrong with this code:

    var options = $(this).closest('div').find("select[name^='q']"); //what should I need to do here???

    var plazosHtml = "";
                    var controller = $(this).val().split('.')[0];
                    var html = "<select id='q' name='q'></select>";
                    $(this).closest('div').find('#q').replaceWith(html);
                    
                    $.ajax({
                        url: '@Url.Content("~/Admin/CurrencyList/")',
                        type: 'POST',
                        dataType: 'json',
                        success: function (data) {
                            var options = $(this).closest('div').find("select[name^='q']"); //what should I need to do here???
                            $.each(data, function () {
                                //alert(this.Description); // came from .NET Dictionary's Key Value pair
                                options.append($('<option />').val(this.CurrID).text(this.Description));
                            });
                        }
                    });
    
                } else {
                    var html = "<input type='text' size='30' id='q' name='q' class='qsbox' />";
                    $(this).closest('div').find('#q').replaceWith(html);
                }

    Please advise.

    Regards,

    Micheale

    Sunday, November 9, 2014 9:59 PM

Answers

  • User-893002196 posted

    Solved!

    var CurrentID = $(this).closest('div');

    CurrentID.find("select[name='q']");

    Thank you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 10, 2014 2:55 AM

All replies

  • User-893002196 posted

    Solved!

    var CurrentID = $(this).closest('div');

    CurrentID.find("select[name='q']");

    Thank you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 10, 2014 2:55 AM
  • User-1926401737 posted

    Hi Micheale,

    Solved!

    var CurrentID = $(this).closest('div');

    CurrentID.find("select[name='q']");

    Congratulations on solving the problem by yourself.

    Best Regards,

    Sw-ing

    Monday, November 10, 2014 8:33 PM