title: I can't seem to define a variable to the value of a form
body: <p>Hello fellow programmers, i'm trying to make a website that makes a route description, but I can't assign a variable to the input form.
  I am trying to assign the variable "Bval" (B value) To the green select form, and "Aval" (A value) To the blue select form. Could anyone point out the issue in this code?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
  
    $('#selectroomA').change(function() {
     Aval = $('#selectroomA').value;
    });
  
   $('#selectroomB').change(function() {
    Bval = $('#selectroomB').value;
   });
   
   $('#submit').click(function() {
        console.log('clicked');
    if (Aval === "a001") {
              console.log('Aval = a001');
     if (Bval === "a001") {
                console.log('Bval = a001');
       alert('Je bent al in de A001');
     }
    } else {
            console.log('error with if statements');
          }
   });
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    margin: 0px;
    padding: 0px;
    font-family: Roboto;
  }
        
  .map-box {
    width: 600px;
    height: 300px;
    background: lightgrey;
    overflow: scroll;
  }
  .svg-container {
    width: 80%;
    margin-left: 10%;
    margin-right: 10%;
    overflow: scroll;
    background: lightgrey;
  }
  .material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 1px;  /* Preferred icon size */
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    /* Support for all WebKit browsers. */
    -webkit-font-smoothing: antialiased;
    /* Support for Safari and Chrome. */
    text-rendering: optimizeLegibility;
    /* Support for Firefox. */
    -moz-osx-font-smoothing: grayscale;
    /* Support for IE. */
    font-feature-settings: 'liga';
  }
  
  
  /* Buildings */
  #building {
    transition: 0.4s fill ease-in-out;
  }
  .building-a {
    height: 180px;
    width: 120px;
    fill: #455a64;
  }
  .building-a1 {
    height: 180px;
    width: 120px;
    fill: #1976D2;
  }
  .building-a2 {
    height: 180px;
    width: 120px;
    fill: #388E3C;
  }
  #a0 {
    opacity: 1;
  }
  #a1 {
    opacity: 0;
    transition: 0.4s opacity ease-in-out;
  }
  #a2 {
    opacity: 0;
    transition: 0.4s opacity ease-in-out;
  }
  
  /* Rooms */
  #room {
    fill: #607d8b;
    transition: 0.4s fill ease-in-out;
  }
  
  /* Paths */
  #generalpath {
    fill: white;
  }
  .path {
    transition: 0.3s opacity ease-in-out;
  }
  #a0path1, #a0path2, #a0path3, #a001pathty, #a002path, #a003path, #a004path, #a0stairpath {
    fill: #F44336;
    opacity: 0;
  }
  
  /* Form */
  fieldset {
    border: none;
  }
  select {
    font-family: Roboto;
    background: white;
    color: black;
    padding: 5px;
    margin: 5px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
  }
  button {
    margin-top: 12px;
  }
  #selectroomA {
    background: #40C4FF;
  }
  #selectroomB {
    background: #00E676;
  }
  
  /* Buttons */
  .buttons {
    display: block;
  }
  .upButton, .downButton {
    font-family: Roboto;
    background: #EEE;
    color: black;
    transition: 0.4s all ease-in-out;
    border-radius: 2px;
    text-align: center;
    width: 30px;
    height: 30px;
    margin-top: 5px;
    margin-left: 5px;
    cursor: pointer;
    float: right;
  }
  .upButton, .downButton:hover {
    box-shadow: 2px 2px 6px #37474F;
    background-color: white;
  }
  #button i {
    margin-top: 4px;
    font-size: 22px;
  }
  .disabled {
    font-family: Roboto;
    background: #CCC;
    color: grey;
    transition: 0.4s all ease-in-out;
    border-radius: 2px;
    text-align: center;
    width: 30px;
    height: 30px;
    margin-top: 5px;
    margin-left: 5px;
    cursor: default;
    float: right;
  }
  /* Toolbar */
  #toolbartop {
    width: 77%;
    padding-top: 10px;
    padding-left: 2%;
    padding-right: 1%;
    margin-left: 10%;
    margin-right: 7%;
    background-color: #607D8B;
    color: white;
  }
  .selection {
    display: block;
    padding-right: 10px;
    white-space: nowrap;
  }
  .selection select {
    vertical-align: middle;
    margin-left: 10px;
  }
  #A {
    float: left;
  }
  #B {
    float: left;
  }
  #submit {
    width: 77%;
    height: 30px;
    padding-top: 10px;
    padding-left: 2%;
    padding-right: 1%;
    margin-left: 10%;
    margin-right: 7%;
    background-color: #455A64;
    color: white;
    text-align: center;
    cursor: pointer;
    transition: 0.4s background-color ease-in-out;
  }
  #submit:hover {
    background-color: #546E7A;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
    &lt;head&gt;
     &lt;script
    src="https://code.jquery.com/jquery-3.2.1.min.js"
    integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
    crossorigin="anonymous"&gt;&lt;/script&gt;
      &lt;script src="code.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" type="text/css" href="style.css"&gt;
      &lt;link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id="toolbartop"&gt;
        &lt;form method="post"&gt;
          &lt;div class="selection"&gt;
            &lt;fieldset class="ui-field-contain"&gt;
              &lt;div id="A"&gt;
                &lt;select name="selectroomA" id="selectroomA"&gt;
                  &lt;option value="null"&gt;Selecteer startpunt&lt;/option&gt;
                  &lt;optgroup label="A-gebouw"&gt;
                    &lt;option value="a001"&gt;A001&lt;/option&gt;
                    &lt;option value="a002"&gt;A002&lt;/option&gt;
                    &lt;option value="a003"&gt;A003&lt;/option&gt;
                    &lt;option value="a004"&gt;A004&lt;/option&gt;
                    &lt;option value="a005"&gt;A005&lt;/option&gt;
                  &lt;/optgroup&gt;
                &lt;/select&gt;
              &lt;/div&gt;
              &lt;div id="B"&gt;
              &lt;select name="selectroomB" id="selectroomB"&gt;
                &lt;option value="null"&gt;Selecteer bestemming&lt;/option&gt;
                &lt;optgroup label="A-gebouw"&gt;
                  &lt;option value="a001"&gt;A001&lt;/option&gt;
                  &lt;option value="a002"&gt;A002&lt;/option&gt;
                  &lt;option value="a003"&gt;A003&lt;/option&gt;
                  &lt;option value="a004"&gt;A004&lt;/option&gt;
                  &lt;option value="a005"&gt;A005&lt;/option&gt;
                &lt;/optgroup&gt;
              &lt;/select&gt;
              &lt;/div&gt;
            &lt;/fieldset&gt;
          &lt;/div&gt;
        &lt;/form&gt;
        &lt;div class="buttons"&gt;
          &lt;div id="button" class="upButton" onselectstart="return false"&gt;&lt;i class="material-icons"&gt;arrow_upward&lt;/i&gt;&lt;/div&gt;
          &lt;div id="button" class="downButton" onselectstart="return false"&gt;&lt;i class="material-icons"&gt;arrow_downward&lt;/i&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="submit" onselectstart="return false"&gt;Maak route&lt;/div&gt;
      
      &lt;div class="svg-container"&gt;
      &lt;svg class="map-box" xmlns="http://www.w3.org/2000/svg"&gt;
        &lt;g id="a0"&gt;
          &lt;!-- Staircase --&gt;
          &lt;g class="staircase"&gt;
            &lt;rect x='160px' y='16px' height='35px' width='26px' id="building" fill="#455a64" /&gt;
            &lt;rect x='175px' y='40px' height='10px' width='11px' fill="#2196f3"/&gt;
            
            &lt;rect x='175px' y='39px' height='4px' width='11px' fill="#2196f3"/&gt;
            &lt;rect x='175px' y='33px' height='4px' width='11px' fill="#2994E7"/&gt;
            &lt;rect x='175px' y='27px' height='4px' width='11px' fill="#368DCF"/&gt;
            &lt;rect x='160px' y='16px' height='9px' width='26px' fill="#3E8AC2"/&gt;
            &lt;rect x='160px' y='27px' height='4px' width='11px' fill="#4B85AE"/&gt;
            &lt;rect x='160px' y='33px' height='4px' width='11px' fill="#5A7F95"/&gt;
            &lt;rect x='160px' y='39px' height='4px' width='11px' fill="#607D8B"/&gt;
          &lt;/g&gt;
           
          &lt;!-- Building --&gt;
          &lt;rect x='130px' y='50px' class="building-a" id="building"/&gt;
          &lt;rect x='330px' y='50px' class="building-a" id="building"/&gt;
          
          &lt;!-- Rooms --&gt;
          &lt;rect x='213px' y='200px' width="35px" height="30px" id="room" class="a001"/&gt;
          
          &lt;rect x='130px' y='110px' width="30px" height="57px" id="room" class="a002"/&gt;
          
          &lt;rect x='130px' y='50px' width="30px" height="57px" id="room" class="a003"/&gt;
          
          &lt;rect x='130px' y='170px' width="30px" height="50px" id="room" class="a004"/&gt;
          &lt;rect x='130px' y='200px' width="80px" height="30px" id="room" class="a004"/&gt;
          
          &lt;rect x='185px' y='50px' width="25px" height="40px" id="room" class="a007"/&gt;
          
          &lt;!-- General Path --&gt;
          &lt;rect x='164px' y='179px' width="85px" height="17px" id="generalpath"/&gt;
          &lt;rect x='164px' y='50px' width="17px" height="137px" id="generalpath"/&gt;
          
          &lt;!-- Specific paths --&gt;
          &lt;rect x='169px' y='185px' width="65px" height="7px" id="a0path1" class="path"/&gt;
          &lt;rect x='169px' y='135px' width="7px" height="50px" id="a0path2" class="path"/&gt;
          &lt;rect x='169px' y='75px' width="7px" height="60px" id="a0path3" class="path"/&gt;
          
          &lt;rect x='228px' y='185px' width="7px" height="15px" id="a001path" class="path"/&gt;
          &lt;rect x='160px' y='135px' width="15px" height="7px" id="a002path" class="path"/&gt;
          &lt;rect x='160px' y='75px' width="15px" height="7px" id="a003path" class="path"/&gt;
          &lt;rect x='160px' y='185px' width="15px" height="7px" id="a004path" class="path"/&gt;
            
          &lt;rect x='169px' y='50px' width="7px" height="60px" id="a0stairpath" class="path"/&gt;
          &lt;rect x='163px' y='18px' width="5" height="32px" id="a0stairpath" class="path"/&gt;
          &lt;rect x='163px' y='18px' width="16" height="5px" id="a0stairpath" class="path"/&gt;
          &lt;rect x='178px' y='18px' width="5" height="32px" id="a0stairpath" class="path"/&gt;
        &lt;/g&gt;
        
        &lt;g id="a1"&gt;
          &lt;!-- Staircase --&gt;
          &lt;rect x='160px' y='16px' height='35px' width='11px' id="building" fill="#1976D2"/&gt;
          &lt;rect x='160px' y='16px' height='10px' width='26px' id="building" fill="#1976D2"/&gt;
          &lt;rect x='175px' y='16px' height='35px' width='11px' id="building" fill="#1976D2"/&gt;
          &lt;rect x='175px' y='40px' height='10px' width='11px' fill="#4CAF50"/&gt;
          
          &lt;rect x='175px' y='39px' height='4px' width='11px' fill="#4CAF50"/&gt;
          &lt;rect x='175px' y='33px' height='4px' width='11px' fill="#41A977"/&gt;
          &lt;rect x='175px' y='27px' height='4px' width='11px' fill="#3DA788"/&gt;
          &lt;rect x='160px' y='16px' height='9px' width='26px' fill="#36A2A5"/&gt;
          &lt;rect x='160px' y='27px' height='4px' width='11px' fill="#2E9EBE"/&gt;
          &lt;rect x='160px' y='33px' height='4px' width='11px' fill="#279AD9"/&gt;
          &lt;rect x='160px' y='39px' height='4px' width='11px' fill="#2196F3"/&gt;
          
          &lt;!-- Building --&gt;
          &lt;rect x='130px' y='50px' class="building-a1" id="building"/&gt;
          
        &lt;/g&gt;
        
        &lt;g id="a2"&gt;
          &lt;rect x='130px' y='50px' class="building-a2" id="building"/&gt;
        &lt;/g&gt;
      &lt;/svg&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Does anyone know what i did wrong? If so thanks in advance.</p>