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

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?