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
Solved

Jquery datepicker implementation

Posted on 2011-03-18
1
393 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

829 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