Solved

JQuery Calendar - won't disappear on date selection

Posted on 2011-03-15
1
388 Views
Last Modified: 2012-05-11
Hi I had this problem before but realised it was caused by bad JQuery syntax.  I'm a JQuery newbie so please bear with me :-).  It was ever since I added the code to set the date field to tomorrow's date that it started going wrong.  I'd be grateful if someone could tell me where I'm going wrong in my syntax.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<title>Cross Keys Hotel, London/title>

<link rel="stylesheet" type="text/css" href="styles/baseline.css" />
<link rel="stylesheet" type="text/css" href="styles/jquery.lightbox-0.5.css" media="screen" />
<link rel="stylesheet" type="text/css" href="styles/jquery-ui.css" media="screen" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>

<script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>

<script type="text/javascript">

$(document).ready(function() {

$('#Date').datepicker({
			onSelect: function(dateText, inst) {
				var s = dateText.split("/");
				$("#$DAY$").val(s[2]);
				$("#$MONTH$").val(s[1]);
				$("#$YEAR$").val(s[0]);
			}

		}); 

$("#Date").datepicker('option', {dateFormat: 'dd/mm/yy'}); 

var myDate = new Date();
    var day = myDate.getDate() + 1;
    var month = myDate.getMonth() + 1;
    var ukDate = day + '/' + month + '/' + myDate.getFullYear();
    $("#Date").val(ukDate);

$('a[rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel

});

</script>
</head>



<body id="county" class="booking"> 

<div id="booking">
<h3>Find &amp; Book</h3>
<form name="bookingForm" id="bookingForm" method="post" action="http://www.hotelexec.co.uk/external.asp" autocomplete="off">
<fieldset>
<input name="$LICENCE$" type="hidden" value="xxxxxx" />
<input name="$SMOKING$" type="hidden" value="" />

<input name="$SOURCE$" type="hidden" value="" />
<input name="$LEDGER$" type="hidden" value="" />
<input name="$DAY$" id="Day" type="hidden" value="" />
<input name="$MONTH$" id="Month" type="hidden" value="" />
<input name="$YEAR$" id="Year" type="hidden" value="" />
<label for="Date">Arrival <br/> Date</label>
<input id="Date" name="Date" type="text" value="" autocomplete="off" class="required" />
<label for="Nights">Number <br/> of nights</label>
<!--<input id="Nights" name="$NIGHTS$" type="text" value="1" />-->
<select id="Nights" name="$NIGHTS$">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>

<option value="20">20</option>
<option value="21">21</option>
</select>
<input type="submit" name="Submit" value="Check for Availability" class="submit" />
</fieldset>
</form>
</div>

</body>
</html>

Open in new window

0
Comment
Question by:Lorna70
[X]
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
1 Comment
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 250 total points
ID: 35142681
Use 1 assignment of the the datepicker to your #Date element.
$('#Date').datepicker({
	onSelect: function(dateText, inst) {
		var s = dateText.split("/");
		$("#$DAY$").val(s[2]);
		$("#$MONTH$").val(s[1]);
		$("#$YEAR$").val(s[0]);
	},
	dateFormat: 'dd/mm/yy'
});

Open in new window

0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

707 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