0 Replies Latest reply on Aug 10, 2015 2:05 PM by NewApexCoder

    Populate select list with database values using JSON

    NewApexCoder

      Forgive me if I'm posting in the wrong place or if my question is too vague.

       

      I am having trouble populating a select list with database values. I am trying to accomplish this with html, an oracle database, and JSON. 

      In my html file (Contracts.htm), I have my html select list as the following:

       

      <select id="contract_numbers" name="contract_number"></select>
      

       

      I want the [option][/option] tags to hold the values of a query. The query would be as simple as:

       

      Select contract_name
      From MYTABLE
      WHERE contract_date > '01/12/2015'
      

       

      I have created a package in the database to handle all my procedures and functions. This is about as far as my understanding goes of how to accomplish this with JSON. I also have a Contracts.js file to hold my functions, variables, etc.

      I also have a Contracts.js file. It has the following function:

      function LoadTestSelectList() {
         var itter;
         var dropdown;
         var done = 30;
         dropdown =$("#contract_numbers");
      
         for (itter=20; itter<done; ++itter) {
              var id = itter;
              var option = $('<option/>', {value: id, text: id
             });
      
         dropdown.append(option);
        }
      

       

      Overly basic, I know, but this just populates my select list with values from 20-29, via the iterator. My problem is trying to populate this select list with values from a database query. This is where I am stuck at.

      I am a beginner using JSON and hope the description of my problem is enough to be understood. I realize this is a lot, but any help on this topic would be greatly appreciated. Thanks in advance.