How to dropdown bind according to this recordHow do JavaScript closures work?How can I upload files asynchronously?How do I check if an element is hidden in jQuery?Event binding on dynamically created elements?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

Examples where existence is harder than evaluation

Why does this pattern in powers happen?

Capturing the entire webpage with WebExecute's CaptureImage

How could a civilization detect tachyons?

Is it possible to do moon sighting in advance for 5 years with 100% accuracy?

Two (probably) equal real numbers which are not proved to be equal?

why it is 2>&1 and not 2>>&1 to append to a log file

Why are thrust reversers not used down to taxi speeds?

How do I give a darkroom course without negatives from the attendees?

What will Doctor Strange protect now?

Why is there a cap on 401k contributions?

Is there an application which does HTTP PUT?

Steganography in Latex

Can radiation block all wireless communications?

How do I calculate my to-hit bonus when using the Great Weapon Master feat?

Is there a reason why Turkey took the Balkan territories of the Ottoman Empire, instead of Greece or another of the Balkan states?

Why is it wrong to *implement* myself a known, published, widely believed to be secure crypto algorithm?

How can it be that ssh somename works, while nslookup somename does not?

Did any early RISC OS precursor run on the BBC Micro?

How can I test a shell script in a "safe environment" to avoid harm to my computer?

Whose birthyears are canonically established in the MCU?

Align a table column at a specific symbol

Is the tensor product (of vector spaces) commutative?

Why did Ham the Chimp push levers?



How to dropdown bind according to this record


How do JavaScript closures work?How can I upload files asynchronously?How do I check if an element is hidden in jQuery?Event binding on dynamically created elements?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have two loops:



  • table loop: fills the table rows

  • dropdown loop: fills the dropdowns with typeid.data[i].TypeId, add a select in the last dropdown

My dropdown does not fill according to its record and I don't understand why.



 var QuestionId = data[i].QuestionOid;
var fkid = data[i].FkSource;
var selectdata = data[i];
var selectinnerhtml = "<span><select id = "answer" + QuestionId + "" name = "answer" + QuestionId + "" class="answer" + QuestionId + " form-control input-small" > </select></span>";
$.ajax(
type: "GET",
dataType: 'json',
contentType: 'application/json; charset=utf-8',
url: '/MYaPI/EmployeeDetails/' + data[i].TypeId,
success: function(datasa)
var optionhtmls = '<option value="' +
0 + '">' + "--Select--" + '</option>';

$(".answer" + QuestionId).append(optionhtmls);

$.each(datasa, function(j)
var optionhtmls = '<option value="' +
datasa[j].Oid + '">' + datasa[j].Title + '</option>';

$(".answer" + QuestionId).append(optionhtmls);
);

);
var newRows2select = "<tr class='rows'><a href = '' >" +
" <td QuestionCategoryTitle = " + selectdata.QuestionCategoryTitle + " QuestionHeader = " + selectdata.QuestionHeader + " ContentTypeId=" + selectdata.FkSource + " QuestionTypeId=" + selectdata.FkQuestionType + " QuestionOID=" + selectdata.QuestionOid + " CategoryOID=" + selectdata.FkQuestionCategory + " class="question-block"><small style="color:slateblue;font-weight: bolder;display:none">CATEGORY: " + selectdata.QuestionCategoryTitle + ",</small>" +
" <i class="deleteRow fas fa-trash float-right"></i> " +
"<p> " + selectdata.QuestionHeader + "</p>" + selectinnerhtml + " </td></a> "</tr>";
$("#table23").append(newRows2select);


enter image description here










share|improve this question






























    0















    I have two loops:



    • table loop: fills the table rows

    • dropdown loop: fills the dropdowns with typeid.data[i].TypeId, add a select in the last dropdown

    My dropdown does not fill according to its record and I don't understand why.



     var QuestionId = data[i].QuestionOid;
    var fkid = data[i].FkSource;
    var selectdata = data[i];
    var selectinnerhtml = "<span><select id = "answer" + QuestionId + "" name = "answer" + QuestionId + "" class="answer" + QuestionId + " form-control input-small" > </select></span>";
    $.ajax(
    type: "GET",
    dataType: 'json',
    contentType: 'application/json; charset=utf-8',
    url: '/MYaPI/EmployeeDetails/' + data[i].TypeId,
    success: function(datasa)
    var optionhtmls = '<option value="' +
    0 + '">' + "--Select--" + '</option>';

    $(".answer" + QuestionId).append(optionhtmls);

    $.each(datasa, function(j)
    var optionhtmls = '<option value="' +
    datasa[j].Oid + '">' + datasa[j].Title + '</option>';

    $(".answer" + QuestionId).append(optionhtmls);
    );

    );
    var newRows2select = "<tr class='rows'><a href = '' >" +
    " <td QuestionCategoryTitle = " + selectdata.QuestionCategoryTitle + " QuestionHeader = " + selectdata.QuestionHeader + " ContentTypeId=" + selectdata.FkSource + " QuestionTypeId=" + selectdata.FkQuestionType + " QuestionOID=" + selectdata.QuestionOid + " CategoryOID=" + selectdata.FkQuestionCategory + " class="question-block"><small style="color:slateblue;font-weight: bolder;display:none">CATEGORY: " + selectdata.QuestionCategoryTitle + ",</small>" +
    " <i class="deleteRow fas fa-trash float-right"></i> " +
    "<p> " + selectdata.QuestionHeader + "</p>" + selectinnerhtml + " </td></a> "</tr>";
    $("#table23").append(newRows2select);


    enter image description here










    share|improve this question


























      0












      0








      0








      I have two loops:



      • table loop: fills the table rows

      • dropdown loop: fills the dropdowns with typeid.data[i].TypeId, add a select in the last dropdown

      My dropdown does not fill according to its record and I don't understand why.



       var QuestionId = data[i].QuestionOid;
      var fkid = data[i].FkSource;
      var selectdata = data[i];
      var selectinnerhtml = "<span><select id = "answer" + QuestionId + "" name = "answer" + QuestionId + "" class="answer" + QuestionId + " form-control input-small" > </select></span>";
      $.ajax(
      type: "GET",
      dataType: 'json',
      contentType: 'application/json; charset=utf-8',
      url: '/MYaPI/EmployeeDetails/' + data[i].TypeId,
      success: function(datasa)
      var optionhtmls = '<option value="' +
      0 + '">' + "--Select--" + '</option>';

      $(".answer" + QuestionId).append(optionhtmls);

      $.each(datasa, function(j)
      var optionhtmls = '<option value="' +
      datasa[j].Oid + '">' + datasa[j].Title + '</option>';

      $(".answer" + QuestionId).append(optionhtmls);
      );

      );
      var newRows2select = "<tr class='rows'><a href = '' >" +
      " <td QuestionCategoryTitle = " + selectdata.QuestionCategoryTitle + " QuestionHeader = " + selectdata.QuestionHeader + " ContentTypeId=" + selectdata.FkSource + " QuestionTypeId=" + selectdata.FkQuestionType + " QuestionOID=" + selectdata.QuestionOid + " CategoryOID=" + selectdata.FkQuestionCategory + " class="question-block"><small style="color:slateblue;font-weight: bolder;display:none">CATEGORY: " + selectdata.QuestionCategoryTitle + ",</small>" +
      " <i class="deleteRow fas fa-trash float-right"></i> " +
      "<p> " + selectdata.QuestionHeader + "</p>" + selectinnerhtml + " </td></a> "</tr>";
      $("#table23").append(newRows2select);


      enter image description here










      share|improve this question
















      I have two loops:



      • table loop: fills the table rows

      • dropdown loop: fills the dropdowns with typeid.data[i].TypeId, add a select in the last dropdown

      My dropdown does not fill according to its record and I don't understand why.



       var QuestionId = data[i].QuestionOid;
      var fkid = data[i].FkSource;
      var selectdata = data[i];
      var selectinnerhtml = "<span><select id = "answer" + QuestionId + "" name = "answer" + QuestionId + "" class="answer" + QuestionId + " form-control input-small" > </select></span>";
      $.ajax(
      type: "GET",
      dataType: 'json',
      contentType: 'application/json; charset=utf-8',
      url: '/MYaPI/EmployeeDetails/' + data[i].TypeId,
      success: function(datasa)
      var optionhtmls = '<option value="' +
      0 + '">' + "--Select--" + '</option>';

      $(".answer" + QuestionId).append(optionhtmls);

      $.each(datasa, function(j)
      var optionhtmls = '<option value="' +
      datasa[j].Oid + '">' + datasa[j].Title + '</option>';

      $(".answer" + QuestionId).append(optionhtmls);
      );

      );
      var newRows2select = "<tr class='rows'><a href = '' >" +
      " <td QuestionCategoryTitle = " + selectdata.QuestionCategoryTitle + " QuestionHeader = " + selectdata.QuestionHeader + " ContentTypeId=" + selectdata.FkSource + " QuestionTypeId=" + selectdata.FkQuestionType + " QuestionOID=" + selectdata.QuestionOid + " CategoryOID=" + selectdata.FkQuestionCategory + " class="question-block"><small style="color:slateblue;font-weight: bolder;display:none">CATEGORY: " + selectdata.QuestionCategoryTitle + ",</small>" +
      " <i class="deleteRow fas fa-trash float-right"></i> " +
      "<p> " + selectdata.QuestionHeader + "</p>" + selectinnerhtml + " </td></a> "</tr>";
      $("#table23").append(newRows2select);


      enter image description here







      javascript jquery ajax dom-events






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 7:47









      Brian Tompsett - 汤莱恩

      4,2671339105




      4,2671339105










      asked Mar 21 at 12:47









      Addi KhanAddi Khan

      1617




      1617






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I don't know the jQuery way, however it is easily achievable with plain JavaScript



          var select = document.createElement("select");
          var selectinnerhtml = document.createElement("span");
          selectinnerhtml.appendChild(select);
          $.each(datasa, function(j)

          //create a new option element
          var option = document.createElement("option");

          //set the value attribute
          option.setAttribute("value", datasa[j].oid);

          //fill the HTML tag
          option.value = datasa[j].Title

          //add the option to the select dropdown
          select.add(option);
          );





          share|improve this answer























          • i think its shows wrong result because after we add second dropdown automatically dropdown option bind second one not first

            – Addi Khan
            Mar 21 at 13:03











          • Could you clarify?

            – EsliS
            Mar 21 at 13:05












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280792%2fhow-to-dropdown-bind-according-to-this-record%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I don't know the jQuery way, however it is easily achievable with plain JavaScript



          var select = document.createElement("select");
          var selectinnerhtml = document.createElement("span");
          selectinnerhtml.appendChild(select);
          $.each(datasa, function(j)

          //create a new option element
          var option = document.createElement("option");

          //set the value attribute
          option.setAttribute("value", datasa[j].oid);

          //fill the HTML tag
          option.value = datasa[j].Title

          //add the option to the select dropdown
          select.add(option);
          );





          share|improve this answer























          • i think its shows wrong result because after we add second dropdown automatically dropdown option bind second one not first

            – Addi Khan
            Mar 21 at 13:03











          • Could you clarify?

            – EsliS
            Mar 21 at 13:05
















          0














          I don't know the jQuery way, however it is easily achievable with plain JavaScript



          var select = document.createElement("select");
          var selectinnerhtml = document.createElement("span");
          selectinnerhtml.appendChild(select);
          $.each(datasa, function(j)

          //create a new option element
          var option = document.createElement("option");

          //set the value attribute
          option.setAttribute("value", datasa[j].oid);

          //fill the HTML tag
          option.value = datasa[j].Title

          //add the option to the select dropdown
          select.add(option);
          );





          share|improve this answer























          • i think its shows wrong result because after we add second dropdown automatically dropdown option bind second one not first

            – Addi Khan
            Mar 21 at 13:03











          • Could you clarify?

            – EsliS
            Mar 21 at 13:05














          0












          0








          0







          I don't know the jQuery way, however it is easily achievable with plain JavaScript



          var select = document.createElement("select");
          var selectinnerhtml = document.createElement("span");
          selectinnerhtml.appendChild(select);
          $.each(datasa, function(j)

          //create a new option element
          var option = document.createElement("option");

          //set the value attribute
          option.setAttribute("value", datasa[j].oid);

          //fill the HTML tag
          option.value = datasa[j].Title

          //add the option to the select dropdown
          select.add(option);
          );





          share|improve this answer













          I don't know the jQuery way, however it is easily achievable with plain JavaScript



          var select = document.createElement("select");
          var selectinnerhtml = document.createElement("span");
          selectinnerhtml.appendChild(select);
          $.each(datasa, function(j)

          //create a new option element
          var option = document.createElement("option");

          //set the value attribute
          option.setAttribute("value", datasa[j].oid);

          //fill the HTML tag
          option.value = datasa[j].Title

          //add the option to the select dropdown
          select.add(option);
          );






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 21 at 12:54









          EsliSEsliS

          938




          938












          • i think its shows wrong result because after we add second dropdown automatically dropdown option bind second one not first

            – Addi Khan
            Mar 21 at 13:03











          • Could you clarify?

            – EsliS
            Mar 21 at 13:05


















          • i think its shows wrong result because after we add second dropdown automatically dropdown option bind second one not first

            – Addi Khan
            Mar 21 at 13:03











          • Could you clarify?

            – EsliS
            Mar 21 at 13:05

















          i think its shows wrong result because after we add second dropdown automatically dropdown option bind second one not first

          – Addi Khan
          Mar 21 at 13:03





          i think its shows wrong result because after we add second dropdown automatically dropdown option bind second one not first

          – Addi Khan
          Mar 21 at 13:03













          Could you clarify?

          – EsliS
          Mar 21 at 13:05






          Could you clarify?

          – EsliS
          Mar 21 at 13:05




















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280792%2fhow-to-dropdown-bind-according-to-this-record%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

          밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

          1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴