[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

javascript date

Hi experts,

I need a code that fullfill fday, fmonth, fyear from start-date value.

here is my code

<form action="http://hotel.reservit.com/reservit/reserhotel.php" method="post" target="_blank" id="formulaire_quicksearch">
<input type="hidden" name="lang" value="EN" />
<input type="hidden" name="hotelid" value="11907" />
<input type="hidden" name="fday" id="jour_arrivee" value=""/>
<input type="hidden" name="fmonth" id="mois_arrivee" value="" />
<input type="hidden" name="fyear" id="annee_arrivee" value="" />

Date d'arrivée:<input type="text" id="start-date" name="start-date" value=""/>
<br>Nuit(s):<select class="champ_quicksearch"  id="nombre_nuits" name="nbnights" ><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><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option></select>
<br>Adulte(s):<select class="champ_quicksearch"  id="nombre_adultes" name="nbadt" ><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></select>
<br><input class="champ_quicksearch" type="submit" value="Book" />
<br><a href="http://hotel.reservit.com/reservit/reserhotel.php?hotelid=11907&lang=FR" title="Options" target="_blank" class="lien_quicksearch">Options</a>

  • 2
  • 2
1 Solution
put this in the head section :

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript"></script>
$(document).ready(function() {
        onSelect: function(dateText, inst) {
            var dt = dateText.split("/");

Open in new window

after downloading them, put the js files on your own server (check the first lines)

test page : http://jsfiddle.net/puDcE/
jQuery for this? Really?

Put this in the <head> section of your page:
function stuff_date() {
    var da = document.getElementById("start-date").value; // Start date
    var ra = da.split("/"); // Month, day and year (at least in the U.S.)
    document.getElementById("mois_arrivee").value = ra[0];
    document.getElementById("jour_arrivee").value = ra[1];
    document.getElementById("annee_arrivee").value = ra[2];
    return ra; // In case you need the M, D, and/or Y

Open in new window

erezabouAuthor Commented:
to leakim971:

can you please check why your code is not working on my page.


Not willing to try my solution, eh?
can't locate lines 4 to 15
I only saw that :
jQuery(function($){$( "#start-date" ).datepicker({}); $( "#end-date" ).datepicker({});});

Open in new window


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now