title: PHP - Using getElementByID or $_POST
body: <p>I have a WordPress theme which uses a combination of PHP/JS/AJAX to present a booking form.</p>
  
  <p>I am trying to access the value of an output field which is rendered by the following:</p>
  
  <pre><code>&lt;div class="output"&gt;
      &lt;p&gt;&lt;?php _e('Check-in', 'bookyourtravel') ?&gt;&lt;/p&gt;
      &lt;p class="step_1_date_from_holder" id="pccfromdate"&gt;&lt;/p&gt;
      &lt;p&gt;&lt;?php if (!empty($accommodation_check_in_time)) { echo ' ' . $accommodation_check_in_time; } ?&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I need to get the value from the pccfromdate text. The variables that I have seen through the booking process at <a href="http://epiccloudshare.com/penninelettings/hotel/curlew-yurt-village/" rel="nofollow">http://epiccloudshare.com/penninelettings/hotel/curlew-yurt-village/</a> are as follows:</p>
  
  <p><code>$date_from</code> (set up in a .js file)</p>
  
  <p><code>$selected_date_from</code> (seen when I do a Chrome "inspect element")</p>
  
  <p>I have tried </p>
  
  <pre><code>&lt;?php $date_from2 = document.getElementByID('pccfromdate').value; ?&gt;
  </code></pre>
  
  <p>but if my understanding is starting to develop, this is not possible because PHP is server side and JS is client side</p>
  
  <p>The form has a POST method against it so I also tried</p>
  
  <pre><code>&lt;?php if(isset($_POST['selected_date_from']))
      $date_from2 = $_POST['selected_date_from']; ?&gt;
  </code></pre>
  
  <p>Any pointers would be appreciated</p>
  
  <p>EDIT</p>
  
  <p>I did not indicate that the <code>$_POST</code> attempt did not work either.
  So, as indicated by machavity I <strong>think</strong> the answer is something to do with AJAX as the value I require is displayed via the <code>step_1_date_from_holder</code> class. I am able to modify the php script to assign a <code>name</code> and/or <code>id</code> to the <code>&lt;p&gt;</code> but I haven't got a clue as to how to use AJAX to get at the actual value to get it back into a PHP variable.</p>