title: Auto-select Dropdown option based on previous answer - Javascript HTML Form
body: <p>First time posting so apologies if it may question is at first unclear, although I hope it's fairly straight forward. I'm new to Javascript and need some help. </p>
  
  <p><strong>WHAT I WANT TO ACHIEVE:</strong> </p>
  
  <p>I have an HTML form and when someone selects a letter from the 'letter' dropdown menu in the HTML form (e.g. A, B, or C), I want the 'number' dropdown menu to change automatically based on the select in the 'letter' dropdown (e.g. if letter selected was 'A' then select '1', if 'B' then select '2' and so on.)</p>
  
  <p>[[ As a bonus, it also like the 'number' dropdown to be disabled, so automatic variable generated cannot be changed by the front-end user filling out the form]]</p>
  
  <p><strong>FURTHER INFORMATION</strong></p>
  
  <p>I had seen something similar down on a form I had permission to use so I tried to ammend the code but I can't make it work. If you could provide tips on how to ammend the code or provide a new answer to my problem that would be fantastic.</p>
  
  <p><strong>MY CODE (so far...)</strong></p>
  
  <p>The Javascript Part</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
  &lt;?php
         echo "var campus='none';";
  ?&gt;
  
  &lt;script language ="javascript"&gt;
   function changeDropdown(number) {
                  numberSelection = document.getElementById("number");
                  for (var i = 0; i &lt; numberSelection.length; i++)
                  {
                      if (number == numberSelection[i].value)
                      {
                          numberSelection[i].selected = true;
                          return;
                      }
                  }
              }
  
  function load() {
  
      if (number == 'none')
                  {
                      letterSelection = document.getElementById("letter");
  
                      if letter == letterSelection("0")
                      {
                          changeDropdown("A");
                      }
                      else if letter == letterSelection("1")
                      {
                          changeDropdown("B");
                      }
                      else if letter == letterSelection("2")
                      {
                          changeDropdown("C");
                      }
  
                  }
                  else
                  {
                      changeDropdown(number);
                  }
  
  }
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  </code></pre>
  
  <p>The Form</p>
  
  <pre><code>&lt;form name ="form1"&gt;
  &lt;select name ="letter" onclick="load()"&gt;
  &lt;option value ="A"&gt;A
  &lt;option value ="B"&gt;B
  &lt;option value ="C"&gt;C
  &lt;/option&gt;
  &lt;/select&gt;
  
  &lt;br /&gt;
  
  &lt;select name ="number"&gt;
  &lt;option value ="1"&gt;1
  &lt;option value ="2"&gt;2
  &lt;option value ="3"&gt;3
  &lt;/option&gt;
  &lt;/select&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any clarification, just ask and I'm very happy to respond :)</p>