title: concatenation occurs besides sum
body: <p>i am trying to build a calculator but in that i am unable to perform sum operation besides it concatenation is occurred how i can do this sum, also how to empty the text box when entering new value in the text-box after pressing '=' my code is this </p>
  
  <p>
      </p>
  
  <pre><code>    &lt;title&gt;Calculator&lt;/title&gt;
      &lt;script&gt;
      var v = 0 ;
      var operator = '';
      function calc(obj){
  
      if (obj.value == '+' || obj.value == '-' || obj.value == '*' || obj.value == '/'  ){
       v = document.getElementById("text_field").value;
       operator = obj.value;
          document.getElementById("text_field").value = '';
  
          }
  else if (obj.value == '='){
  
              if (operator == '+')
          {
          document.getElementById("text_field"). value = v + document.getElementById("text_field").value  ;
  
          }   
          if (operator == '-')
          {
          document.getElementById("text_field").value = v - document.getElementById("text_field").value  ;
  
          }   
          if (operator == '*')
          {
          document.getElementById("text_field").value =v * document.getElementById("text_field").value  ;
  
          }   
          if (operator == '/')
          {
          document.getElementById("text_field").value = v /  document.getElementById("text_field").value  ;
  
          }   
          }
      else {
           document.getElementById("text_field").value = document.getElementById("text_field").value + obj.value;
      }
  
      }
  
  
  
  
  
  
      &lt;/script&gt;
  </code></pre>