Problem Statement:All the data of First form are not getting into the backend file(ReserveRoomsBackend.php) which include start_date, end_date,sr_citizen_choice which may be loosing at between of program so on submitting it is not passed to another page so what should be the solution for this .
IN Reserve.html file i have used two files
1.findReserveRoomsBackend.php is the file in which it will find out the free rooms and return a single room and the respective building
I think that when the findReserveRoomsBackend.php return the room number then dates are lost
2.ReserveRoomsBackend.php file for mysql connectivity and insert the data of form into the MYSQL database.
The following is the Reserve.html file
<html>
<script type="text/javascript" src="../jQuery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
document.getElementById("form_reserve").style.display = "none";
document.getElementById("label").style.display = "none";
});
function doAjaxPost(){
var from_date = document.getElementById("from_date").value;
var end_date = document.getElementById("end_date").value;
var no_of_males= document.getElementById("id_males").value;
var no_of_females=document.getElementById("id_females").value;
var no_of_childrens=document.getElementById("id_childrens").value;
var sr_citizen ;
for (var i=0; i < document.reserve_rooms.sr_citizen_choice.length; i++)
{
if (document.reserve_rooms.sr_citizen_choice[i].checked)
{
var sr_citizen = document.reserve_rooms.sr_citizen_choice[i].value;
}
}
//.getJSON -- get building id, building name, room number
// if building id > 0 show the reservation details form
// else show the messgae
//findReserveRoomsBackend.php is the file in which it will find out the free rooms and //return a single room and the respective building
//I think that when the findReserveRoomsBackend.php return the room number then dates are //lost
//findReserveRoomsBackend.php file for mysql connectivity and insert the date of form into the MYSQL database
var link = 'http://localhost/findReserveRoomsBackend.php?start_date='+from_date+' & end_date='+end_date+' & sr_citizen_choice='+sr_citizen+' & no_of_males='+no_of_males+'& no_of_females='+no_of_females+' & no_of_childrens='+no_of_childrens;
$.getJSON(link,function(json)
{
if( json.length> 0)
{
document.form_reserve.action ="http://localhost/ReserveRoomsBackend.php? bldg_number="+json[0].bldg_number +" & room_number="+json[0].room_number;
document.getElementById("form_reserve").style.display = "block";
}
else
{
document.getElementById("label").style.display = "block";
}
alert("inside json finction " + json.length+" "+json[0].room_number+" "+json[0].bldg_number);
}); //.getJSON
}//doAjaxPost
</script>
<div style="width: 950px; height: 500px; background-color: #FAE89E; border-width: 3px; border-style: inset; color: #FF0000; font-size: 13px; font-family: Arial; overflow: auto;">
<script type="text/javascript" src="../jQuery.js"></script>
<script type="text/javascript" src="../jquery.ui.datepicker.js"></script>
<script language="javascript" type="text/javascript" src="datetimepicker.js"> </script>
<body>
------This is the First form---------------------------------------------------------------
<form id='target' METHOD="POST" name='reserve_rooms'>
<p> From Date:<input name="from" type="text" id ="from_date"/>
End Date:<input name="to" type="text" id="end_date" />
Senior Citizen*:<input type = "radio" name = "sr_citizen_choice" value = "Y" />Yes
<input type = "radio" name = "sr_citizen_choice" value = "N" checked />No
<input id="find_availability" type="button" value="Find Availability" onClick="doAjaxPost()" />
</p>
</form>
<div id='label' name ='label'>
No Rooms are available for the given period
</div>
--This is the second form-----------------------------------
<form id='form_reserve' name='form_reserve' " METHOD="POST">
<fieldset>
<legend>Personal Details :</legend>
<b>Name*:</b> <input type="text" name="fname" />
Address*:<input type="text" size=50 width=30 name="faddress"/>
City*:<input type="text" name="fcity" />
State*:</b> <input type="text" name="fstate" />
Country*:<select name="gourl" size="1">
<option>India</option>
</select>
</fieldset>
<input type="submit" value="Reserve Room"/>
</form>
</body>
</html>