title: innerHTML - how to assign value and display to div id in javascript
body: <blockquote>
    <p>I'd created checkDay function for get value of input type text field and check value with if/else condition and give desire out through innerHTML to the target div #id.</p>
    
    <p>Problem is I want to avoid all time to write "document.getElementById("showDay").innerHTML ". Is there a way to write simple code, which will perform same result? </p>
    
    <p>working code - <a href="http://jsfiddle.net/animatorstar/5chokg76/4/" rel="nofollow">http://jsfiddle.net/animatorstar/5chokg76/4/</a></p>
  </blockquote>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function checkDay()
  {
      
      var a = document.getElementById("enterNumber").value;  
      
      if (a==0)  //condition
      {
          alert("value of a is "+a);  //statements
          document.getElementById("showDay").innerHTML = "Enter value between 1-7";
      }
      
      if (a==1)  //condition
      {
          alert("value of a is "+a);  //statements
          document.getElementById("showDay").innerHTML = "Entered value is " + a + ", " + "Day is Monday";
      }
      
      else if (a==2)  //condition
      {
          alert("value of a is "+a);  //statements
          document.getElementById("showDay").innerHTML = "Entered value is " + a + ", " + "Day is Tuesday";
      }
      
      else if (a==3)  //condition
      {
          alert("value of a is "+a);  //statements
          document.getElementById("showDay").innerHTML = "Entered value is " + a + ", " + "Day is Wendesday";
      }
      
      else if (a==4)  //condition
      {
          alert("value of a is "+a);  //statements
          document.getElementById("showDay").innerHTML = "Entered value is " + a + ", " + "Day is Thursday";
      }
      
      else if (a==5)  //condition
      {
          alert("value of a is "+a);  //statements
          document.getElementById("showDay").innerHTML = "Entered value is " + a + ", " + "Day is Friday";
      }
      
      else if (a==6)  //condition
      {
          alert("value of a is "+a);  //statements
          document.getElementById("showDay").innerHTML = "Entered value is " + a + ", " + "Day is Saturday";
      }
      
      else if (a==7)  //condition
      {
          alert("value of a is "+a);  //statements
          document.getElementById("showDay").innerHTML = "Entered value is " + a + ", " + "Day is Sunday";
      }
      
      else
      {
          alert("Wrong value - Enter value between 1-7");  //statements
      }
      
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="text" id="enterNumber" name="" placeholder="Enter number for check value" /&gt;
  
  &lt;button onClick="checkDay();"&gt; Check Value &lt;/button&gt;
  
  &lt;br&gt;
  &lt;div id="showDay"&gt; &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>