title: Passing values from a DIV element to an input
body: <p>I have a PHP calendar form (generated from <a href="http://style-vs-substance.com/code/calendar-class-php/" rel="nofollow">http://style-vs-substance.com/code/calendar-class-php/</a> as a base, but heavily customised and updated) which outputs two month at a time - 30/31 days, in a tabular format. </p>
  
  <p>What I am trying to create is a booking form for business meetings, whereby the client user can click on a date on the HTML calendar and the value of the date <em>as in the whole date value - not just the day</em> is passed to the input field.</p>
  
  <p>I would like to achieve something like (pseudo code):
  <em>(calendar month of March 2015)</em></p>
  
  <pre><code>   &lt;td&gt;&lt;div value='13032015' id='something'&gt;13&lt;/div&gt;&lt;/td&gt;
  </code></pre>
  
  <p>On clicking this date box, the JQuery rule is fired and the value is passed to the input which is further down the page and formatted into something like:</p>
  
  <pre><code>&lt;input type='text' value='13th March 2015' name='dateA' id='dateA'&gt; 
  </code></pre>
  
  <p>My initial issue is, <strong>can I take a unseen value from a DIV (rather than <em>innerHTML</em>) using jQuery and pass it to the input (with appropriate formatting)?</strong> </p>
  
  <p>Part 1 - How to get JQuery to take a value from the DIV, I can place values into the input - that's easy, but I would need a unique ID for each div in the table (60+) and I'm not going to write out 60+ JQuery rules, one for each div id, there must be a better more dynamic way of doing this.</p>
  
  <p>Part 2 - Once I have a value selected, how would I go about formatting the value to make it a full date rather than the code date identifier? Something similar to PHP <code>date()</code> function.</p>
  
  <p>So, What would be the best JQuery way of achieving this? I am wary of generating a custom JQuery Var for each day as that's 60+ days on each page load, seems quite inefficient.  </p>
  
  <p>I am currently using JQuery 1.11.1 for other things on the page, and would be looking to use this rather than JQuery 2. </p>
  
  <h2>EDIT:</h2>
  
  <p>Could I take the DIV id value - so :</p>
  
  <pre><code>&lt;td&gt;&lt;div id='13032015'&gt;13&lt;/div&gt;&lt;/td&gt;
  </code></pre>
  
  <p>And somehow use the id string of <code>13032015</code> to become the date string in the input?</p>