Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery UI, multiple datepickers on single page
    primarykey
    data
    text
    <p>I'm creating a PHP site for property. I'm new to jQuery and jQuery UI but can't seem to find the answer anywhere else.</p> <p>Please see this screen shot (<a href="https://i.stack.imgur.com/b3yQX.png" rel="nofollow noreferrer">full size</a>):</p> <p><img src="https://i.stack.imgur.com/b3yQX.png" alt="Screen shot"></p> <p>For for every "received" and "expiry" box I want a jQuery datePicker box to appear and format as shown.</p> <p>To test this I tried to create an example.</p> <pre><code>&lt;link type="text/css" href="css/ui-lightness/jquery-ui-1.8.9.custom.css" rel="Stylesheet" /&gt; &lt;script type="text/javascript" src="js/jquery-1.4.4.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/jquery-ui-1.8.9.custom.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(function() { $( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' }); $( "#datepicker2" ).datepicker({ dateFormat: 'yy-mm-dd' }); }); &lt;/script&gt; &lt;style&gt; .ui-datepicker { font-size: 80%; } &lt;/style&gt; &lt;p&gt;Date: &lt;input id="datepicker" type="text" /&gt;&lt;/p&gt; &lt;p&gt;Date2: &lt;input id="datepicker2" type="text" /&gt;&lt;/p&gt; </code></pre> <p>Which works fine, but how do I get a date picker to come up for ANY textbox without having to repeat the JS so many times.</p> <p>For say, 50 properties, there may be 200 input boxes on the page with a date needing to be filled in.</p> <p>Here is some example code from the screen shot.</p> <pre><code>&lt;tr&gt; &lt;td&gt;Property ID&lt;/td&gt; &lt;td&gt;House Number&lt;/td&gt; &lt;td&gt;Address Line 1&lt;/td&gt; &lt;td&gt;Gas Expiry&lt;/td&gt; &lt;td&gt;Gas Received&lt;/td&gt; &lt;td&gt;Electric Expiry&lt;/td&gt; &lt;td&gt;Electric Received&lt;/td&gt; &lt;td&gt;Property Active&lt;/td&gt; &lt;td&gt;Update&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;4&lt;/td&gt; &lt;td&gt;6&lt;/td&gt; &lt;td&gt;East Street&lt;/td&gt; &lt;td&gt;&lt;input name="gas_expiry[4]" type="text" id="gas_expiry[4]" value="2011-08-03" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="gas_received[4]" type="text" id="gas_received[4]" value="" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="electric_expiry[4]" type="text" id="electric_expiry[4]" value="" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="electric_received[4]" type="text" id="electric_received[4]" value="" /&gt;&lt;/td&gt; &lt;td&gt; &lt;select name="active[4]" id="active[4]"&gt; &lt;option value="0" selected="selected"&gt;No&lt;/option&gt; &lt;option value="1"&gt;Yes&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;td&gt;&lt;input name="edit[]" type="checkbox" id="edit[]" value="4" /&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Probably something really simple, I appreciate any help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload