Solved

jQuery DatePicker on a table with multiple rows

Posted on 2010-11-19
2
681 Views
Last Modified: 2012-05-10
Hi,

I have a table as follows:

<ul class="xyz">
   <li>Date</li>
   <li>Start</li>
   <li>End</li>
</ul>
<ul class="abc">
   <li><input type="text" name="date0" id="date"></li>
   <li><...></li>
   <li><...></li>
</ul>
<ul class="abc">
   <li><input type="text" name="date1" id="date"></li>
   <li><...></li>
   <li><...></li>
</ul>
.
.
.
<ul class="abc">
   <li><input type="text" name="date100" id="date"></li>
   <li><...></li>
   <li><...></li>
</ul>

The last row can be any number as it depends on the number of queries being pulled out of the database.

Currently my datepicker scripts says

$(function() {       
        $( "#date" ).datepicker({
              minDate: 0,
              changeMonth: true,
              changeYear: true,
              dateFormat: 'dd-mm-yy',
              showOn: "button",
              buttonImage: "/images/calendar.gif",
              buttonImageOnly: true,
               showOtherMonths: true,
              selectOtherMonths: true              
        });      
});       

How do I change it so that it is executed whenever the user tries to select a date in any 'dateX' field?

Thanks

0
Comment
Question by:jagku
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
marceloOrigoni earned 500 total points
ID: 34174271
the best way, is to add a class="date" to each field, like this:

<ul class="abc">
   <li><input type="text" name="date100" id="date" class="date"></li>
   <li><...></li>
   <li><...></li>
</ul>

and then execute the datepicker like this:

$(function() {      
        $( ".date" ).datepicker({
              minDate: 0,
              changeMonth: true,
              changeYear: true,
              dateFormat: 'dd-mm-yy',
              showOn: "button",
              buttonImage: "/images/calendar.gif",
              buttonImageOnly: true,
               showOtherMonths: true,
              selectOtherMonths: true              
        });      
});  

Marcelo
0
 

Author Closing Comment

by:jagku
ID: 34174332
Excellent - many thanks!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question