Hi all,
I am developing a form and im wanting to know why when i am using my ajax/jquery form its not displaying my form located on my create booking page this is my code i have
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#submit").submit(function(){
$.post("createbooking.php",
$("#submit").serialize(),
function(data)
{
//alert(data);
$("#bookmiddle").html(data);
}
);
});
});
</script>
<div style="margin-left:50px;">
<form method="post" id="submit" onsubmit="return false;">
<table>
<tr>
<th colspan="3">Event Date</th>
</tr>
<tr>
<th><select name="Day">
<?php
$day = date('d');
$month = date('n');
$days_in_month = date('t', strtotime($year . '-' . $month . '-1'));
for($i=1;$i<=$days_in_month; $i++)
{
//
if($i == $day)
{
echo '<option value="'.$i.'" selected="selected">'.$i.'</option>';
}
else
{
echo '<option value="'.$i.'">'.$i.'</option>';
}
//
}?>
</select>
</th>
<th><select name="Month">
<?php
//$months_in_year = date('t', strtotime($month . '-' . $day . '-1'));
for($i=$month;$i<=12; $i++)
{
$month_of_year = date($i);
echo '<option value="'.$i.'">';
if($i == 1)
{
echo 'Jan';
}
else if($i == 2)
{
echo 'Feb';
}
else if($i == 3)
{
echo 'March';
}
else if($i == 4)
{
echo 'April';
}
else if($i == 5)
{
echo 'May';
}
else if($i == 6)
{
echo 'June';
}
else if($i == 7)
{
echo 'July';
}
else if($i == 8)
{
echo 'Aug';
}
else if($i == 9)
{
echo 'Sept';
}
else if($i == 10)
{
echo 'Oct';
}
else if($i == 11)
{
echo 'Nov';
}
else if($i == 12)
{
echo 'Dec';
}
echo '</option>';
}?>
</select>
</th>
<th></th>
</tr>
<tr>
<th colspan="3"><input type="submit" name="save" value="Book Event" /></th>
</tr>
</table>
</form>
On the create booking page i have
$month = $_POST['Month'];
$year = date('Y');
include("dbconnect.php");
$cQuery="SELECT * FROM Booking WHERE Day='$Day' AND Month='$month' AND Year='$year'";
//echo $cQuery;
$rs=mysqli_query($con,$cQuery);
if(!$rs)
{
echo "Error:".mysqli_error($con);
}
else
{
$count=$rs->num_rows;
if($count>0)
{
//
echo "This Day is Taken";
//
}
else
{
//
echo "Works";
?>
<form method="post" action="">
<input type="hidden" name="Day" value="<?php echo $Day;?>"/>
<input type="hidden" name="Month"value="<?php echo $month;?>"/>
<input type="hidden" name="Year" value="<?php echo $year;?>"/>
<input type="hidden" name="invoice" value="DJRS<?php echo randAlphaNum(8);?>" />
<br/>
<table style="background-color:#FFF; margin-left:15px">
<tr>
<th>Day Selectede</th>
<th><?php echo "".$Day." Of ".$month." ".$year.""; ?></th>
</tr>
<tr>
<th>First Name</th>
<th><input type="text" name="fname" /></th>
</tr>
<tr>
<th>Last Name</th>
<th><input type="text" name="lname" /></th>
</tr>
<tr>
<th>Address</th>
<th><input type="text" name="addy" /></th>
</tr>
<tr>
<th>Country</th>
<th><input type="text" name="country" /></th>
</tr>
<tr>
<th>Guests</th>
<th> <select name="Guests">
<option value="25-50">25-50</option>
<option value="50-100">50-100</option>
<option value="100-150">100-150</option> <option value="150+">150+</option>
</select>
</th>
</tr>
<tr>
<th>Event Location</th>
<th><input type="text" name="elocation" /></th>
</tr>
<tr>
<th>Event Time</th>
<th><input type="text" name="etime" /></th>
</tr>
<tr>
<th>Home Phone</th>
<th><input type="text" name="hphone" /></th>
</tr>
<tr>
<th>DJ Plan:</th>
<th><select name="plan">
<?php
ShowPlans();
?>
</select></th>
</tr>
<tr>
<th>Mobile Phone</th>
<th><input type="text" name="mphone" /></th>
</tr>
<tr>
<th>Email:</th>
<th><input type="text" name="email" /></th>
</tr>
<tr>
<th colspan="2"><input type="submit" value="Create Booking" name="submit"/></th>
</tr>
</table></form>
<?php
}
}
Why isnt the form on the booking creation page not showing the table and form on the creation page only shows my word “works”?
What am i doing wrong how can i fix this?
Thanks,William