Help with jquery datepicker
Here is what I have so far: I'm trying to get it so that when I click the calendar icon, the datepicker pops up also. Just like when the text box is clicked.
Thanks for the help.
<html>
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14 /themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme /ui.theme.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://jqueryui.com/demos/demos.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$.datepicker.setDefaults($.datepicker.regional['']);
$('#date').datepicker();
});
$(function()
{
$('.date-pick').datePicker({clickInput:true})
});
</script>
</head>
<body>
<?php
$da = $_POST['date'];
$y= substr($da, 6, 4);开发者_JS百科
$m= substr($da, 0, 2);
$d= substr($da, 3, 2);
print "IT IS " . $y . "-" . $m . "-" . $d;
?>
<form name="oemail" method="post" action="<?php print $_SERVER['PHP_SELF'] ?>">
<label for="date">The Date:</label>
<input type="text" name="date" id="date" readonly></input><img class="date-pick" src="calendar.png"></img>
<input type="submit" id="sub"> </input>
</form>
</body>
</html>
You've got a stray capital P
:
$('.date-pick').datepicker({clickInput:true})
You will have to bind the click() event of the image to the date picker.
Try this one:
$("img.date-pick").click(function(e) {
$('#date').datepicker("show");
});
Without any javascript:
<label for="date"><img src='calendarPicture.png'/></label>
like in this http://jsfiddle.net/RYKTx/
精彩评论