|
|
|
เลือกวันที่ใน DatePicker แล้วหน้าเว็บเด้งไปข้างบนสุด |
|
|
|
|
|
|
|
เวลาเลือวันที่ใน datepicker พอเลือกแล้วหน้าเพจเด้งขึ้นไปบนสุด ไม่อยู่ตตรงตำแหน่งเดิมครับ พอจะมีวิธีแก้ไหมครับ
Form
<link type="text/css" href="css/jquery-ui-1.8.2.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/booking.js"></script>
<form action="https://ibe.hoteliers.guru/ibe/search-room-rate" method="get">
<input type="hidden" name="hotel_id" value="8">
<div class="col-md-1 col-sm-1 booking">Check in :</div>
<div class="col-md-2 col-sm-2 booking2">
<input type="text" id="indate" name="check_in" readonly="readonly" class="input1" value="check in" />
</div>
<div class="col-md-1 col-sm-1 booking">Check out :</div>
<div class="col-md-2 col-sm-2 booking2">
<input type="text" id="outdate" name="check_out" readonly="readonly" class="input1" value="check out" onchange="dateDifference();" />
</div>
<div class="col-md-2 col-sm-2 booking3">
<select id="chknoadult" name="total_adult[0]" class="input3">
<option value="1" selected="selected">1 Adults</option>
<option value="2">2 Adults</option>
<option value="3">3 Adults</option>
<option value="4">4 Adults</option>
<option value="5">5 Adults</option>
<option value="6">6 Adults</option>
</select>
</div>
<div class="col-md-2 col-sm-2 booking3">
<select id="chknochild" name="total_child[0]" onchange="javascript: displayAgeOfChildren2(this.value,1);">
<option value="0" selected="selected">0 Children</option>
<option value="1">1 Children</option>
<option value="2">2 Children</option>
<option value="3">3 Children</option>
<option value="4">4 Children</option>
<option value="5">5 Children</option>
<option value="6">6 Children</option>
</select>
</div>
<div class="col-md-2 col-sm-2">
<center><input type="submit" onclick="available('searchavailable');" class="booknow" value="BOOK NOW" /></center>
</div>
</form>
booking.js
Code (JavaScript)
$().ready(function() {
$(".lightbox").lightbox();
var currentTime = new Date();
var smonth = currentTime.getMonth() + 1;
var smonth = (smonth < 10) ? '0' + smonth : smonth;
var sday = currentTime.getDate();
var sday = (sday < 10) ? '0' + sday : sday;
var syear = currentTime.getFullYear();
$("#indate").val(syear + "-" + smonth + "-" +sday );
var outdate = new Date(currentTime.setDate(currentTime.getDate() + 1));
var emonth = outdate.getMonth() + 1;
var emonth = (emonth < 10) ? '0' + emonth : emonth;
var eday = currentTime.getDate();
var eday = (eday < 10) ? '0' + eday : eday;
var eyear = currentTime.getFullYear();
$("#outdate").val(eyear + "-" + emonth + "-" +eday);
function parseDate(input) {
var parts = input.match(/(\d+)/g);
// new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
return new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based
}
function customStart(input) {
var newDate = $(this).datepicker("getDate");
if (newDate) {
newDate.setDate(newDate.getDate() + 1);
}
$("#outdate").datepicker().datepicker("enable");
$("#outdate").datepicker("setDate", newDate);
dateDifference();
}
function customEnd(input) {
var newDate = $("#indate").datepicker("getDate");
if (newDate) {
newDate.setDate(newDate.getDate() + 1);
}
$("#outdate").datepicker("option", "minDate", newDate);
}
function available(frmObj){
var form = document.getElementById(frmObj);
form.setAttribute("method", "get");
form.setAttribute("action", "https://secure.widediscovery.com/v2.1/wdsystem.php");
var HotelhiddenField = document.createElement("input");
HotelhiddenField.setAttribute("type", "hidden");
HotelhiddenField.setAttribute("id", "hotel");
HotelhiddenField.setAttribute("name", "hotel");
HotelhiddenField.setAttribute("value", "00332");
form.appendChild(HotelhiddenField);
var HotelhiddenField = document.createElement("input");
HotelhiddenField.setAttribute("type", "hidden");
HotelhiddenField.setAttribute("id", "sd");
HotelhiddenField.setAttribute("name", "sd");
HotelhiddenField.setAttribute("value", $('#indate').val());
form.appendChild(HotelhiddenField);
var HotelhiddenField = document.createElement("input");
HotelhiddenField.setAttribute("type", "hidden");
HotelhiddenField.setAttribute("id", "ed");
HotelhiddenField.setAttribute("name", "ed");
HotelhiddenField.setAttribute("value", $('#outdate').val());
form.appendChild(HotelhiddenField);
var HotelhiddenField = document.createElement("input");
HotelhiddenField.setAttribute("type", "hidden");
HotelhiddenField.setAttribute("id", "rooms");
HotelhiddenField.setAttribute("name", "rooms");
HotelhiddenField.setAttribute("value", $('#chknoofroom :selected').val());
form.appendChild(HotelhiddenField);
var HotelhiddenField = document.createElement("input");
HotelhiddenField.setAttribute("type", "hidden");
HotelhiddenField.setAttribute("id", "adult");
HotelhiddenField.setAttribute("name", "adult");
HotelhiddenField.setAttribute("value", $('#chknoadult :selected').val());
form.appendChild(HotelhiddenField);
var HotelhiddenField = document.createElement("input");
HotelhiddenField.setAttribute("type", "hidden");
HotelhiddenField.setAttribute("id", "child");
HotelhiddenField.setAttribute("name", "child");
HotelhiddenField.setAttribute("value", $('#chknochild :selected').val());
form.appendChild(HotelhiddenField);
form.submit();
}
function dateDifference(){
var strDate1=document.getElementById("indate").value;
var strDate2=document.getElementById("outdate").value;
datDate1= parseDate(strDate1);
datDate2= parseDate(strDate2);
if(((datDate2-datDate1)/(24*60*60*1000))>=0){
document.getElementById("night").value=((datDate2-datDate1)/(24*60*60*1000));
}
}
Tag : HTML/CSS, JavaScript, jQuery
|
ประวัติการแก้ไข 2017-01-09 21:10:50
|
|
|
|
|
Date :
2017-01-09 21:09:17 |
By :
bakerylove |
View :
1229 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองใช้ DatePicker ตัวนี้นะครับ
|
|
|
|
|
Date :
2017-01-10 11:55:37 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|