i am newbie in javascript...
i have problem here, i want to pass the value (date) to database script (php)
i want only the matched keyword will be displayed. i try several method but still did not get the right result as desrved.
someone please alter my code. tq
index.html
//check date
$('#submit_date').click(function(){
var data_date = $('.date').val();
if(data_date == ""){
alert('Date Empty');
$('.date').focus();
return false;
}
else if(!validate_date(data_date)){
alert('Invalid Date. Correct format is dd/mm/yyyy');
return false;
}
else if(validate_date(data_date)){
/* 1st try
$.ajax({
type:"POST",
url:"check_booking.php?q="+data_date,
data:data_date,
success:function(html) {
//$('#date_booked').fadeIn('slow').show();
$('#date_booked').html(result);
}
});*/
/* 2nd try
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
*/
// 3rd try
var url = "check_booking.php?q=" + data_date;
jQuery("#date_booked").load(url);
/* 4th try
$.post('check_booking.php',{'date':data_date},function(sql) {
jQuery("#date_booked").load('check_booking.php');
});
*/
//to proceed
$('#time').fadeIn('slow').show();
return true;
}
});
Enter Date: <input type="text" size="20" class="date" id="date" name="date" value="12/12/2012"/>
<div id="date_booked"><b>Date info will be listed here.</b></div>
check.php
<?php
$q = $_POST['date']; //problem here, Notice: Undefined index: date in C:\xampp\htdocs\bangkok_station\booking\check_file_in_AJAX_ok\check_booking.php on line 2
//connection
$sql = "SELECT * FROM booking WHERE booking_date = '".$q."'";
$result = mysql_query($sql);
//the rest output
?>