Solved

Jquery datepicker implementation

Posted on 2011-03-18
1
390 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
ID: 35169352
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add a 3rd selection to sum 7 27
Html5 Index on a table 7 26
How to retrieve remote exit code when using rsh from Linux to Windows ? 13 41
Scroll 5 news at a time. 4 27
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to dynamically set the form action using jQuery.

770 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