title: Conversion from Decimal to octal, binary and hexadecimal in javascript
body: <p>I have a form where a user enters a decimal number and then from the dropdown menu he chooses if he wants to convert it either to binary, octal or hexadecimal by clicking on a convert button. The new answer should be displayed in a new form saying for example: "the number in binary is....". However the code I've done doesn't seem to work. Any help would be highly appreciated. This is the code I have so far:</p>
  
  <pre><code>   &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt; Convertor &lt;/title&gt;
  
  
  &lt;style&gt;
  
    .panel {
      width:400px;
      height:160px;
      background-color: #E6E6FA;
      border:2px solid blue;  
      font-weight: bold;
      font-size: 110%;   
      margin-left:30px;
      margin-top:15px; 
     }    
  
     p {
      margin-left: 30px;
      margin-top: 15px;
     }
  
     form {
      margin-left: 30px;
      margin-top: 15px;
     }
  
     button {
      margin-left:40px;
      margin-top:10px;
     }
  
  
     .answer {
      width:400px;
      height:90px;
      background-color: #E6E6FA;
      border:2px solid blue;  
      font-weight: bold;
      font-size: 110%;   
      margin-left:30px;
      margin-top:15px; 
     }    
  
     form {
      margin-left: 70px;
      margin-top: 65px;
     }
  
  
  &lt;/style&gt;
  
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div class="panel"&gt;
  
          &lt;p&gt;
              Enter decimal number to convert, select Base and click CONVERT.
          &lt;/p&gt;
  
          &lt;form&gt;
              &lt;input type="text"&gt;
  
  
          &lt;select id="selectid" name="selectname"&gt;
              &lt;option value="binary"&gt;Binary&lt;/option&gt;
              &lt;option value="octal"&gt;Octal&lt;/option&gt;
              &lt;option value="hexadecimal"&gt;Hexadecimal&lt;/option&gt;
          &lt;/select&gt;   
  
          &lt;button id="button1" name="Button1" onclick="Answer()"&gt; Convert 
              &lt;/button&gt;   
  
              &lt;/form&gt;
  
  
      &lt;/div&gt;
  
      &lt;div class="answer"&gt;
          &lt;form&gt;
  
  
          &lt;/form&gt;
  
      &lt;/div&gt;
  
      &lt;script&gt;
  
  
      function Answer() {
  
          if (document.getElementbyId ('selectid').value=="binary") {
              this.value=this.value.toString(2);
          }
          else if  (document.getElementbyId ('selectid').value=="octal") {
              this.value=this.value.toString(8);
          }
          else if  (document.getElementbyId ('selectid').value=="hexadecimal") {
              this.value=this.value.ToString(16);
          }
      }
  
      &lt;/script&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>