views:

81

answers:

3

I am trying to get a date picker working and I am really struggling with my limited javascript knowledge. I have been basing this on this tutorial.

I have the following code:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;    
<script type="text/javascript" src="scripts/date.js"></script>    
<script type="text/javascript" src="scripts/jquery.datePicker.js"></script>    
<script type="text/javascript" charset="utf-8">    
 $(function()    
 {    
  $('.date-pick').datePicker().val(new Date().asString()).trigger('change');
 });    
</script>

...

<input name="oDate" id="oDate" class="date-pick" />

Any suggestions would be very much appreciated.

A: 

I hope you have an input tag like so in your HTML body:

<input name="date" id="date" class="date-pick" />
petsagouris
Sorry, missed that off my post. Editing to include this.
Have you included this in a `<form>`?
petsagouris
And also make sure you've included the `id` attribute with the same name as the `name` attribute.
petsagouris
Yes - <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
A: 

i would suggest you take a look at the regular jquery ui datepicker to get a standard out of the box datepicker working. Start by simply using the exact code you see here and then tweak (step by step) as necessary. There are tons of example for all different use cases and good documentation

ooo
Thanks, I will try this way, I can't get anything to work using the Kelvin Luck one. Even if its copied stright out of the tutorial!
@user368186 - no upvote ?? :)
ooo
+2  A: 

I have tried below configuration and it's working fine on my local host -

Browser Tested - Mozilla Firefox version 3.6.10

I have xampp package installed.

I am including the html file that i have used for testing -

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;    
<script type="text/javascript" src="date.js"></script>   
<script type="text/javascript" src="jquery.datePicker.js"></script>
<LINK REL=StyleSheet HREF="datePicker.css" TYPE="text/css" MEDIA=screen>    
<script type="text/javascript" charset="utf-8">    
 $(function()    
 {    
  $('.date-pick').datePicker().val(new Date().asString()).trigger('change');
  //$('.date-pick').dpSetEndDate('01/01/2010');
 });    
</script>

</head>
<body>
<input name="oDate" id="oDate" class="date-pick" />
</body>
</html> 
Alpesh
This does not work for me. Does this mean that it is a configuration issue? if so what do I need to check is correctly configured?
you are testing on which operating system and which browser ?
Alpesh
I am using debian and I have tested with firefox, iceweasel and chrome and getting nothing each time.
just install firebug ( an addon for mozilla) in your firefox browser. Just check in firebug's console that are you getting any js errors.
Alpesh
On the scripts tab in firebug, there are no scripts for that page
Have you tried checking console (first tab) in firebug ? Because if the plugin js file is not loading then it will show error something like this .datepicker is not a function.
Alpesh