pollysal Posted March 18, 2010 Share Posted March 18, 2010 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> Quote Link to comment https://forums.phpfreaks.com/topic/195689-how-to-assign-textbox-value-as-variables-in-same-page/ Share on other sites More sharing options...
Psycho Posted March 18, 2010 Share Posted March 18, 2010 Form values can only be accessed by the PHP processor when the values are submitted. For example, by clicking a submit button and submitting the form - which would refresh the page. To submit the values without refreshing the page you will need to use AJAX. In this case use JavaScript to submit the values and receive the results. There are plenty of AJAX tutorials to get you started. Quote Link to comment https://forums.phpfreaks.com/topic/195689-how-to-assign-textbox-value-as-variables-in-same-page/#findComment-1028116 Share on other sites More sharing options...
scvinodkumar Posted March 18, 2010 Share Posted March 18, 2010 I dont know whether i understand your question correctly, let me clear first, You want to show the number of days(stay at the hotel) between checkin and checkout date, right? if so, then you can use javascript to find the difference between these two dates before submitting the form Quote Link to comment https://forums.phpfreaks.com/topic/195689-how-to-assign-textbox-value-as-variables-in-same-page/#findComment-1028118 Share on other sites More sharing options...
Psycho Posted March 18, 2010 Share Posted March 18, 2010 I dont know whether i understand your question correctly, let me clear first, You want to show the number of days(stay at the hotel) between checkin and checkout date, right? if so, then you can use javascript to find the difference between these two dates before submitting the form I think I may have misrread that. I thought there was some need for PHP processing (e.g. see if days were available). Yes, if you only need to calculate the days, then you would only need to use JavaScript. Quote Link to comment https://forums.phpfreaks.com/topic/195689-how-to-assign-textbox-value-as-variables-in-same-page/#findComment-1028138 Share on other sites More sharing options...
pollysal Posted March 20, 2010 Author Share Posted March 20, 2010 yeah..i finally realized that i don't need to use php since it's just need to run on the client side to get the days between two days. he..he..i'm still green in this web development, so i don't understand many stuff.. i'll look forward to learn ajax and javascript to implement what i wanted to do.. thanks for those who reply and provide me with the keyword that i needed.. Quote Link to comment https://forums.phpfreaks.com/topic/195689-how-to-assign-textbox-value-as-variables-in-same-page/#findComment-1029311 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.