How to assign textbox value to the variables in the same page?

Discussion in 'PHP' started by sally89, Mar 18, 2010.

  1. #1
    may i know if in php i can assign the textbox value from the user input as variables and then display the result of in the same page.

    assume, user insert the checkin and checkout date, then it wil automatically show the numbers of the day the user will stay at the hotel.

    any suggestion will really appreciates because i have no ideas what should i do ...

    below is the code

    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link rel="stylesheet" type="text/css" media="all" href="calendar-win2k-1.css" title="win2k-cold-1" />
    <script type="text/javascript" src="Kalendar/calendar.js"></script>
    <script type="text/javascript" src="Kalendar/calendar-en.js"></script>
    <script type="text/javascript" src="Kalendar/calendar-setup.js"></script>
    <script type="text/javascript" src="Kalendar/ew.js"></script>
    <script type="text/javascript"></script>
    <title>SistemAPOS</title>
    <style type="text/css">
    <!--
    .style7 {color: #FFFFFF}
    .style8 {
    	color: #000000;
    	font-weight: bold;
    }
    .style10 {color: #FFFFFF; font-weight: bold; }
    .style11 {font-weight: bold}
    -->
    </style>
    
    </head>
    
    <body>
    
    <form action="findroom.php" method="post">
    
      <p>Check Room Availbility</p>
      <p>Date In
        <label>
          <input type="text" name="datein" id="datein" />
          <input name="datein" type="image" id="dateA" src="Kalendar/ew_calendar.gif" width="16" height="15" border="0" />
      <script type="text/javascript">
    					</script>
                </strong>
      <script type="text/javascript">Calendar.setup(
    					{
    						inputField : "datein", // ID of the input field
    						ifFormat : "%Y-%m-%d", // the date format
    						button : "dateA" // ID of the button
    					}
    					);
    					document.write(ifFormat);
    					</script>
        </label>
      </p>
      <p>Date Out
        <input type="text" name="dateout2" id="dateout" />
        <input name="dateout" type="image" id="dateB" src="Kalendar/ew_calendar.gif" width="16" height="15" border="0" />
        </strong>
        <script type="text/javascript">Calendar.setup(
    					{
    						inputField : "dateout", // ID of the input field
    						ifFormat : "%Y-%m-%d", // the date format
    						button : "dateB" // ID of the button
    					}
    					);
    					document.write(ifFormat);
    					</script>
      </p>
      <p>Number of Days : Supposely this is the place where it will display how many days the user will stay</p>
      <p>
        <label>
          <input type="submit" name="Check" id="Check" value="Submit" />
        </label>
      </p>
    </form>
    </body>
    </html>
    
    
    
    Code (markup):
     
    sally89, Mar 18, 2010 IP
  2. guardian999

    guardian999 Well-Known Member

    Messages:
    376
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #2
    you can use
    
    var datein = document.getElementById('datein');
    var dateout = document.getElementById('dateout');
    
    var stay = dateout-datein;
    
    Code (markup):
     
    guardian999, Mar 18, 2010 IP