Solved

jQuery DatePicker on a table with multiple rows

Posted on 2010-11-19
2
682 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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…

724 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