title: Javascript passing parameters to function
body: <p>Rookie question: I have the following JavaScript functions. This works correctly but I don't want to hardcode the strings "Names" and "namesDiv". I want to pass them in as parameters to the getItems().How do I do this?</p>
  
  <p>Edit: The function GetMsg() returns a JSON object: result.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type="button" onclick="getItems(); return false;" value="Go"/&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function getItems() {
     loadingMsg();
     GetMsg("Names", null, callback);
  }
  
  function callback(result, args){
     clearContainer();
     //do stuff
     document.getElementById("namesDiv").append(foo);
  }
  
  function loadingMsg(){
      clearContainer();
      // do stuff
      document.getElementById("namesDiv").append(foo);   
  }
  
  function clearContainer(){
      document.getElementById("namesDiv").innerHTML = "";
  }
  </code></pre>