title: Associating AJAX data with other AJAX data
body: <p>I created my own challenge for the Javascript course I am taking by combining some concepts from past lectures from the course. I want to be able to choose one piece of data from a dropdown box and have a textbox fill with related data from the database. I am pulling the data using ajax. here is the page I have so far:</p>
  
  <p><a href="https://i.stack.imgur.com/nQhOM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nQhOM.png" alt="page view"></a></p>
  
  <p>The data is in a sql database and has been dumped to an 'ajax server' via PHP. I included it on the page for reference. As you can tell, i figured out how to populate the dropdown with the ajax data. here's the code I have so far:</p>
  
  <pre><code>const dataModule = (function(){
  
  //some code
  
  })();
  
  const uiModule = (function(){
  
    const domStrings = {
      dropdown: '.dd',
    }
  
  //get data from ajax
    const dropdown = document.querySelector('.dd');
    const getData = (async function() {
      const data = await (await fetch('http://localhost/Test2/ajaxservers/_family.php')).json();
      data.forEach(cur =&gt; {
        option = document.createElement('option');
        option.text = cur.fname;
        dropdown.add(option);
      });
    })();
  
    return {
      returnDomStrings: function() {
        return domStrings;
      }
    }
  
  })();
  
  const controlModule = (function(data, ui){
  
    const doms = ui.returnDomStrings();
    const setupEL = function() {
      document.querySelector(doms.dropdown).addEventListener('change',select)
    }
  
    const select =  function() {
      let x = document.querySelector(doms.dropdown);
      console.log(x.value);
    }
  
    return {
       init: function() {
        console.log('Application started');
        setupEL();
      }
    }
  
  })(dataModule, uiModule);
  
  controlModule.init()
  </code></pre>
  
  <p>I'm not so sure about the next part. Where do I even start? Please keep in mind that I'm just learning and that I'm not ready for Jquery yet. Keep any tips/answers to vanilla JS. I tried searching for solutions online, but I am not well versed enough in the terminology to know what to specifically search for.</p>