Solved

Jquery datepicker implementation

Posted on 2011-03-18
1
388 Views
Last Modified: 2012-05-11
Hi experts,

Ive got the datepicker working on this page: http://www.deans-place.co.uk/site1/date2.php

Im now trying to implement it into my form. So far ive added the includes for the datepicker to my existing form header so it looks like this....

<link type="text/css" href="themes/custom/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script src="includes/jquery.js"></script>
<script src="includes/ui.core.js"></script>
<script src="includes/ui.datepicker.js"></script>

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="includes/js/jquery.form.js"></script>
 
<script>

  $(document).ready(function() {
    $('#myForm').ajaxForm({
      target: '#showdata',
      success: function() {
        $('#showdata').fadeIn('slow');
      }
    });
  });
</script>

I now need to add the following code for the datepicker into the header. But when I add it the form stops working, any idea why? ...

<script>
$(function() {
$("#datepicker").datepicker({dateFormat: 'dd-mm-yy'});
});
</script>


Many Thanks,
Dean.
0
Comment
Question by:deanlee17
1 Comment
 
LVL 4

Accepted Solution

by:
chuckalicious earned 500 total points
Comment Utility
Couple of things, first of all it looks like you're loading jQuery twice in the head though jQuery.js and jquery-latest.js

So once you've sorted that, your datepicker code does not need to be in a function.

You want the following:

$(document).ready(function() {

    $('#myForm').ajaxForm({
      target: '#showdata',
      success: function() {
        $('#showdata').fadeIn('slow');
      }
    });
$("#datepicker").datepicker({dateFormat: 'dd-mm-yy'});
  });

Should be as easy as that
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now