title: javascript post form.submit();
body: <p>Hi im trying to use javascript to post two strings to another PHP page ( the strings are dynamic and will be created by a JS routine at run time)  </p>
  
  <p>I want to use the below code to open a new window and within the code for that page retrieve the posted data</p>
  
  <p>im using the following code to post</p>
  
  <pre><code>var title_string = "title1|title2";
  var barcode_string = "barcode1|barcode2";
  var path="create_labels.php";
  var method = "post";
  var params = "titles=" + title_string + "&amp;barcodes=" + barcode_string;
      // The rest of this code assumes you are not using a library.
  // It can be made less wordy if you use one.
  var form = document.createElement("form");
  form.setAttribute("method", method);
  form.setAttribute("action", path);
  form.setAttribute("target", "_blank");
  
  for(var key in params) {
      if(params.hasOwnProperty(key)) {
          var hiddenField = document.createElement("input");
          hiddenField.setAttribute("type", "hidden");
          hiddenField.setAttribute("name", key);
          hiddenField.setAttribute("value", params[key]);
  
          form.appendChild(hiddenField);
       }
  }
  
  document.body.appendChild(form);
  form.submit();
  </code></pre>
  
  <p>For simplicity i have just created two strings ( title and barcode) for the time being  which i am going to pass via a post on form.submit</p>
  
  <p>The bit im not sure on is the creation of the params, am i doing this correct?  The code does open a new window but for whatever reason i am unable to retrieve the posted data, i think im posting it wrong.</p>