title: Show/hide drop down list based on selection of another drop down list
body: <p>Yes, I've tried to search answer for this problem and I found many similar questions but none of them seemed to help me. </p>
  
  <p>I have drop down list with few options and when user selects one option, another drop down list appears with correct choices. Yes, this was the easy part but I need to send selected options to a server and that's the tricky part for me. I have created two different drop down lists which pop up after the user has selected one option from the "main" drop down list. Problem is that correct values goes to the server only from the first list that pops up. If I choose value from the 2nd list that pops up, the first option of the 1st list goes to server.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;style type="text/css"&gt;
  .hiddenMenu {display: none;}
  .visibleMenu {display: inline;}
  &lt;/style&gt;
  &lt;script type="text/javascript"&gt;
  var lastDiv = "";
  function showDiv(divName) {
      // hide last div
      if (lastDiv) {
          document.getElementById(lastDiv).className = "hiddenMenu";
      }
      //if value of the box is not nothing and an object with that name exists, then change the class
      if (divName &amp;&amp; document.getElementById(divName)) {
          document.getElementById(divName).className = "visibleMenu";
          lastDiv = divName;
      }
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="http://url.here" method="post" enctype="multipart/form-data"&gt;
      &lt;label for="shirttype"&gt;T-shirt &lt;/label&gt;
      &lt;select name="category" id="shirttype" onchange="showDiv(this.value);"&gt;
          &lt;option value=""&gt;Choose type&amp;hellip;&lt;/option&gt;
          &lt;option value="female"&gt;Female&lt;/option&gt;
          &lt;option value="male"&gt;Male&lt;/option&gt;
      &lt;/select&gt;
      &lt;br/&gt;
      &lt;p id="female" class="hiddenMenu"&gt;
      &lt;label for="shirtsizefemale"&gt;Size &lt;/label&gt;
      &lt;select name="subjectCategory" id="shirtsizefemale"&gt;
          &lt;option value="femaleXS"&gt;XS&lt;/option&gt;
          &lt;option value="femaleS"&gt;S&lt;/option&gt;
      &lt;/select&gt;
      &lt;/p&gt;
      &lt;p id="male" class="hiddenMenu"&gt;
      &lt;label for="shirtsizemale"&gt;Size &lt;/label&gt;
      &lt;select name="subjectCategory" id="shirtsizemale"&gt;
          &lt;option value="maleXS"&gt;XS&lt;/option&gt;
            &lt;option value="maleS"&gt;S&lt;/option&gt;
       &lt;/select&gt;
       &lt;/p&gt;
      &lt;br/&gt;
  &lt;input type="submit" value="Upload"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So, if I select male S to be my shirt. I receive value "femaleXS" in the server. But if I select female S to be my shirt, value goes correctly to server. Only the value from the 1st popping up list goes correctly to the server.</p>
  
  <p>Ok, so then I decided to make only one list that pops up and this list would have all the options. I would just hide the wrong options depending on what type of shirt user selects. Problem is, I run out of JS skills :) This JS code I'm using I got from <a href="http://tycoontalk.freelancer.com/javascript-forum/62976-show-hide-divs-using-drop-down.html" rel="nofollow">here</a>.</p>
  
  <p>Help me out. I guess one drop down list with hidden values would be the best choice but I just don't know how to do it :P</p>