Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,459 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,831 people online right now. Registration is fast and FREE... Join Now!




Javascript help needed!

 
Reply to this topicStart new topic

Javascript help needed!

PHP_noob
3 Aug, 2008 - 10:36 PM
Post #1

New D.I.C Head
*

Joined: 5 Jun, 2008
Posts: 24

Hi there folks pls refer to the following piece of code:

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 date = 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>
                               &
User is offlineProfile CardPM
+Quote Post

PHP_noob
RE: Javascript Help Needed!
3 Aug, 2008 - 11:08 PM
Post #2

New D.I.C Head
*

Joined: 5 Jun, 2008
Posts: 24

For the above codes, I have attached the javascript codes in the <script></script> to check that the checkout date is not smaller than the checkin date. Fyi this is a hotel website and the above codes are for the hotel reservation

Should the above condition exists, an alert box will popup telling the user of the invalid date selection. However, this didn't happen. Anyone knows why?
User is offlineProfile CardPM
+Quote Post

Bardy
RE: Javascript Help Needed!
3 Aug, 2008 - 11:36 PM
Post #3

New D.I.C Head
*

Joined: 30 Jul, 2008
Posts: 11

Have you check that you have javascript enabled on you browser??
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Javascript Help Needed!
4 Aug, 2008 - 01:01 AM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,993



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Try this JavaScript function for comparing dates.

jscrpt

function CheckDates()
{
var q = document.form1.dayin.value;
var d = document.form1.monthin.value;
var e = document.form1.yearin.value;

var d_out = document.form1.dayout.value;
var m_out = document.form1.monthout.value;
var y_out = document.form1.yearout.value;

var g_in = q + "/"+ d + "/" + e;
var kk_out = d_out + "/" + m_out + "/" + y_out;

if (Date.parse(g_in) < Date.parse(kk_out))
{
alert("Invalid date");
return false;
}
else
return true;
}


Hope that helps smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:59PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month