Javascript help needed

Discussion in 'JavaScript' started by php_noobie, Aug 4, 2008.

  1. #1
    Hi there folks pls refer to the following piece of code:
    ---------------------------------------------------
    <head>
    <title>Paradigm Singapore - Home</title>

    <meta name="title" content="Home" />
    <meta name="author" content="Administrator" />
    <meta name="description" content="Paradigm Hotels, Singapore" />
    <meta name="keywords" content="Paradigm" />
    <meta name="Generator" content="Paradigm Singapore. All rights reserved." />
    <meta name="robots" content="index, follow" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <link rel="shortcut icon" href="images/favicon.ico" />
    <link href="css/template_css.css" rel="stylesheet" type="text/css" />
    <style>
    .error{
    color:red;
    font-family:Arial, Helvetics, sans-serif;
    font-size:7 pt;
    }
    </style>
    <script type="text/javascript" language="javascript" >
    function checkform()
    {
    var fuck = new Date();
    q=document.form1.dayin.value;
    d=document.form1.monthin.value;
    e=document.form1.yearin.value;
    d_out=document.form1.dayout.value;
    m_out=document.form1.monthout.value;
    y_out=document.form1.yearout.value;
    g_in=q+" "+d+" "+ e;
    kk_out=d_out+" "+m_out+" "+y_out;
    gh=Date.parse(g_in);
    vb=Date.parse(kk_out);




    if (gh<vb) {
    alert("Invalid date");
    }

    </script>
    </head>
    <body>
    <form name="form1" method="post" onSubmit="return checkform();" action="reservations.html">

    <div id="container">

    <div id="wrapper">

    <table border="0" cellpadding="0" cellspacing="0" width="758">

    <tbody>
    <tr>

    <td>

    <div id="top_outer">

    <div id="logo_outer">
    <div id="logo">
    <a href="index.html"><img src="images/logo.gif" alt="Paradigm Singapore" /></a>
    </div>
    </div>

    <div id="misc_outer">

    </div>

    <div class="clr"></div>

    </div>




    <div id="menu_outer">

    <script type="text/javascript" language="JavaScript" src="js/mainmenu.js"></script>





    <div id="describe" onmouseover="clear_delayhide()" onmouseout="resetit(event)"></div>
    <script type="text/javascript" language="JavaScript1.2" src="js/menu.js"></script>

    </div>

    <div id="banners_outer">
    <div id="banners_inner">
    <div id="banners">
    <img src="images/banners/home.jpg" style="width: 728px;" alt="banner" />
    </div>
    </div>
    </div>




    <div id="content_outer">

    <div id="content_inner">

    <table class="content_table" border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody><tr valign="top">


    <td width="99%">

    <table class="content_table" border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody><tr>
    <td colspan="0">
    <div id="pathway_text">
    <span class="pathway">Home </span>
    </div>
    </td>
    </tr>
    <tr>
    <td colspan="0" class="body_outer">

    <table class="contentpaneopen">
    <tbody><tr>
    <td valign="top">
    <div class="display-col">

    <div class="list-view">

    <div class="list">

    <table border="0" cellpadding="0" cellspacing="0">

    <tbody>
    <tr>

    <td valign="top">

    <div id="div" dir="ltr">
    <div align="center"><strong>Embracing the Art of Hospitality - Paradigm Singapore </strong></div>
    <br/>
    </div>
    <div id="result_box" dir="ltr">
    <p>We believe in combining contemporary elegance and modern efficiency with our Asian grace, warmth and care. So it is not surprising that if you find the familiar smiles and friendly welcome waiting for you. The dramatic first impression of your arrival at Paradigm Singapore will remain with you throughout your stay. </p>
    <p>Our extraordinary lobby surrounded by glass has been voted the best in the world by first class travellers. With its breathtaking location overlooking the Esplanade, it has been a landmark at the heart of Singapore. That stunning sight is offered to our guests at every opportunity; bringing a remarkable sense of space to all our rooms, serving as a spectacular backdrop to our restaurants and making a visit to our spa in the sky a journey to heaven. At street level, key destinations are within easy reach from Paradigm.</p>
    </div>
    </td>

    </tr>
    </tbody>

    </table>

    </div>


    <div class="left">


    <div class="res">

    <div class="top"></div>

    <div class="mid">

    <table class="res-table" border="0" cellpadding="0" cellspacing="0">

    <tbody>
    <tr>

    <td>



    <table border="0" cellpadding="0" cellspacing="0">

    <caption>Check-in</caption>

    <tbody>
    <tr>

    <td>
    <select name="dayin">
    <option value="01">01</option>
    <option value="02" >02</option>
    <option value="03">03</option>
    <option value="04">04</option>
    <option value="05">05</option>
    <option value="06">06</option>
    <option value="07">07</option>
    <option value="08">08</option>
    <option value="09">09</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 selected="selected" value="30">30</option>
    </select>
    <select name="monthin" style="width:50px;">
    <option value="January">Jan</option>
    <option selected="selected" value="February">Feb</option>
    <option value="March">Mar</option>
    <option value="April">Apr</option>
    <option value="May">May</option>
    <option value="June">Jun</option>
    <option value="July">Jul</option>
    <option value="August">Aug</option>
    <option value="September">Sept</option>
    <option value="October">Oct</option>
    <option value="Novemeber">Nov</option>
    <option value="December">Dec</option>
    </select>
    <select name="yearin">
    <option value="2008">2008</option>
    <option value="2009">2009</option>
    <option>2010</option>
    <option>2011</option>
    <option>2012</option>
    <option>2013</option>
    <option>2014</option>
    <option>2015</option>
    </select>
    </td>

    </tr>
    </tbody>

    </table>



    </td>

    <td>



    <table border="0" cellpadding="0" cellspacing="0">

    <caption>Adult</caption>

    <tbody>
    <tr>

    <td>
    <select>
    <option>0</option>
    <option>1</option>
    <option selected>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    </select>
    </td>

    </tr>
    </tbody>

    </table>



    </td>

    <td>



    <table border="0" cellpadding="0" cellspacing="0">

    <caption>Child</caption>

    <tbody>
    <tr>

    <td>
    <select>
    <option selected>0</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    </select>
    </td>

    </tr>
    </tbody>

    </table>



    </td>

    <td>



    <table border="0" cellpadding="0" cellspacing="0">

    <caption>
    Rooms
    </caption>

    <tbody>
    <tr>

    <td>
    <select>
    <option selected>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    </select>
    </td>

    </tr>
    </tbody>

    </table>

    </td>




    </tr>
    <tr>

    <td>


    <table border="0" cellpadding="0" cellspacing="0">

    <caption>Check-out</caption>

    <tbody>
    <tr>

    <td>
    <select name="dayout">
    <option selected="selected" value="01">01</option>
    <option value="02" >02</option>
    <option value="03">03</option>
    <option value="04">04</option>
    <option value="05">05</option>
    <option value="06">06</option>
    <option value="07">07</option>
    <option value="08">08</option>
    <option value="09">09</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>
    </select>
    <select style="width:50px;" name="monthout">
    <option value="January">Jan</option>
    <option selected="selected" value="February">Feb</option>
    <option value="March">Mar</option>
    <option value="April">Apr</option>
    <option value="May">May</option>
    <option value="June">Jun</option>
    <option value="July">Jul</option>
    <option value="August">Aug</option>
    <option value="September">Sept</option>
    <option value="October">Oct</option>
    <option value="Novemeber">Nov</option>
    <option value="December">Dec</option>
    </select>
    <select name="yearout">
    <option value="2008">2008</option>
    <option value="2009">2009</option>
    <option>2010</option>
    <option>2011</option>
    <option>2012</option>
    <option>2013</option>
    <option>2014</option>
    <option>2015</option>
    </select>
    </td>

    </tr>
    </tbody>

    </table>


    </td>

    <td colspan="2">


    <table border="0" cellpadding="0" cellspacing="0">

    <caption>Smoking Floor</caption>

    <tbody>
    <tr>

    <td>
    <input type="radio" name="smk" checked="checked" /> No
    </td>

    <td>
    <input type="radio" name="smk" /> Yes
    </td>

    </tr>
    </tbody>

    </table>


    </td>

    <td>

    <div class="rates"><input type="image" src="images/check.gif" alt="check rates" border="0" /></div>

    </td>

    </tr>
    <tr><td></td></tr>

    </tbody>

    </table>
    </form>

    </div>

    <div class="bot"><a href="accomodations.html"><img src="images/grey-bot1.gif" alt="Learn More" border="0" /></a></div>

    </div>

    <div class="login">

    <div class="top"></div>

    <div class="bot">
    <form name="form2">
    <table class="res-table" border="0" cellpadding="0" cellspacing="0">

    <tbody>
    <tr>

    <td>

    <table border="0" cellpadding="0" cellspacing="0">

    <caption>Account no.</caption>

    <tbody>
    <tr>

    <td><input class="user" /></td>

    </tr>
    </tbody>

    </table>

    </td>

    <td>

    <table border="0" cellpadding="0" cellspacing="0">

    <caption>Password</caption>

    <tbody>
    <tr>

    <td><input class="pass" type="password" /></td>

    </tr>
    </tbody>

    </table>

    </td>

    <td>

    <table border="0" cellpadding="0" cellspacing="0">

    <caption></caption>

    <tbody>
    <tr>

    <td><a href="index2.html"><img src="images/login.gif" style="margin:12px 0px 0px 5px;" alt="Login" border="0" /></a></td>

    </tr>
    </tbody>

    </table>

    </td>

    </tr>
    </tbody>

    </table>
    </form>
    <table class="res-table" border="0" cellpadding="0" cellspacing="0">

    <tbody>
    <tr>

    <td class="lost">Forget <a href="forget.html">Password</a>? No account yet? <a href="register.html">Register</a></td>

    </tr>
    </tbody>

    </table>

    </div>

    </div>





    </div>

    <div class="right">


    <div class="list-view">

    <div class="list">

    <table border="0" cellpadding="0" cellspacing="0">

    <tbody>
    <tr>

    <td valign="top"><a href="online shop/entry.html"><img src="online shop/img/flash/02.1.jpg" alt="" width="137" height="64" border="0" class="promo" /></a></td>
    <td valign="top"><h4>A New Experience </h4>
    <p>Shopping can be made easy with <strong>S</strong>hop <strong>O</strong>nline<strong> P</strong>aradigm (<a href="online shop/entry.html">more</a>)</p></td>

    </tr>
    </tbody>

    </table>

    </div>

    <div class="list last">

    <table border="0" cellpadding="0" cellspacing="0">

    <tbody>
    <tr>

    <!--<td valign="top"><img src="images/promo1.jpg" class="promo" alt="" /></td>-->
    <td valign="top">

    <h4>Highlights</h4>

    <!--Drifting between the rooms of our Paradigm Suite you’ll notice the fine attention to detail taken in creating this contemporary (<a href="">more...</a>)-->

    <div style="background-color:#000; border:1px solid #454545; margin-top:8px; margin-right:8px; padding:6px;width:320px;">

    <div style="background-color:#fff; padding:6px 6px 0px 6px;">


    <div style="float:left; width:auto;">

    <a style=" z-index:10;position:absolute; right:150px; width:180px;height:100px;background-color:#fff;" href="http://www.visitsingapore.com" target="_blank"></a>

    <OBJECTid=banner4 codeBase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 height=114 width=176 align=middle classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000><PARAM NAME="_cx" VALUE="4657"><PARAM NAME="_cy" VALUE="3016"><PARAM NAME="FlashVars" VALUE=""><PARAM NAME="Movie" VALUE="flash/banner4.swf"><PARAM NAME="Src" VALUE="flash/banner4.swf"><PARAM NAME="WMode" VALUE="Window"><PARAM NAME="Play" VALUE="-1"><PARAM NAME="Loop" VALUE="-1"><PARAM NAME="Quality" VALUE="High"><PARAM NAME="SAlign" VALUE=""><PARAM NAME="Menu" VALUE="-1"><PARAM NAME="Base" VALUE=""><PARAM NAME="AllowScriptAccess" VALUE=""><PARAM NAME="Scale" VALUE="ShowAll"><PARAM NAME="DeviceFont" VALUE="0"><PARAM NAME="EmbedMovie" VALUE="0"><PARAM NAME="BGColor" VALUE=""><PARAM NAME="SWRemote" VALUE=""><PARAM NAME="MovieData" VALUE=""><PARAM NAME="SeamlessTabbing" VALUE="1"><PARAM NAME="Profile" VALUE="0"><PARAM NAME="ProfileAddress" VALUE=""><PARAM NAME="ProfilePort" VALUE="0"><PARAM NAME="AllowNetworking" VALUE="all"><PARAM NAME="AllowFullScreen" VALUE="false">
    <embed src="flash/banner4.swf" quality="high" bgcolor="#ffffff" width="176" height="114" name="banner4" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </OBJECT>
    </div>

    <div style="float:right; width:auto;margin:22px 15px 0px 0px;"><a href="http://www.stb.gov.sg" target="_blank"><img src="images/stblogo.jpg" border="0"></a></div>




    <div class="clr"></div>

    </div>

    </div>


    </td>

    </tr>
    </tbody>

    </table>
    </form>
    </div>

    </div>


    </div>

    <div class="clr"></div>

    </div></div>

    </td>
    </tr>
    </tbody></table>

    </td>
    </tr>
    </tbody></table>


    </td>

    </tr>

    </tbody></table>

    </div>
    </div>

    </td>
    </tr>
    </tbody></table>

    </div>

    <script language="JavaScript" src="js/footer.js" type="text/javascript"></script>

    </div>

    </body>
    </html>

    --------------------------------------------------------

    Fyi, I am doing a hotel website and the above codes are for the hotel rooms reservation, whereby the user has to select the check-in and checkout date

    I have attached some codes in <script></script> to check that the checkout date is not smaller smaller than the check-in date, else an alert box will pop up warning the user of the error. However, it is not working as desired. Anyone knows why?
     
    php_noobie, Aug 4, 2008 IP
  2. VishalVasani

    VishalVasani Peon

    Messages:
    560
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,

    Check out below url may help u?
    http://www.w3schools.com/jsref/jsref_parse.asp
     
    VishalVasani, Aug 4, 2008 IP
  3. surendran.u@gmail.com

    surendran.u@gmail.com Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi

    I reviewd the code and tested in my machine. Hopefully i found the solution.
    There is a problem with the Parsing the Date.Before continuing any of the steps please check the value of the gh,vb variables.

    Try the following:

    gh=[some formatting as you did]
    vb=[some formatting as you did]

    alert(gh);
    alert(vb);

    return 0;

    return 0 will not raise an any error and it will stop continuing from the next line.

    Hope this helps to you.

    Feel free to visit my website(Javascript World) :
    http://javascriptgurus.blogspot.com/

    Please let me know my reply resolved the issue or not.

    Regards
    surendran
    +91 93438 30853
    surendran.u@gmail.com
     
    surendran.u@gmail.com, Aug 7, 2008 IP