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

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>



You should be looking at a javascript function to handle this. As the interaction will happen on the client side (aka browser) there is no need to involve the server in this. Now if you needed something added to the page that the browser itself could not process (ie, get some more data from the database) then you would use an AJAX call to a php script that supplies the data (I prefer in a json format) back to the ajax call. Then you will use javascript to update the data to the page.

thanks rustybuddy for provide me with a ideas because i’m realy green in php side. I’ll look forward to start finding the ajax tutorial

Insted of the text boxes you can use select box and then you can apply your query. It could be the better solution .Recently i have worked on something similar using following ajax method -

http://roshanbh.com.np/2008/01/populate-triple-drop-down-list-change-options-value-from-database-using-ajax-and-php.html

with mootools -

http://youngdutchdesign.com/examples/cvlinkselect.php

Hope this ll help.:slight_smile: