title: How to pass an element ID into parameters of a function? HTML/JS
body: <pre><code>function ValueLimit(min, max, mode){
  
          var v;
          if(mode === "h"){
              v = document.getElementById("weight_imp").value;
  
              if(v &lt; min){document.getElementById("weight_imp").value = min;}
              if(v &gt; max){document.getElementById("weight_imp").value = max;}
          }
  
          if(mode === "w"){
              v = document.getElementById("weight_imp").value;
  
              if(v &lt; min){document.getElementById("weight_imp").value = min;}
              if(v &gt; max){document.getElementById("weight_imp").value = max;}
          }
      }
  </code></pre>
  
  <p>I need to replace mode with an ID of an input element
  This should in turn make the code significantly smaller
  I cannot seem to find a way to pass it through
  It should be able to target any element on the page</p>