Hi I’m just new using YII,
can someone help me with regards to custom function. My objective is to call my function checkAvailability(param… , …) when the user clicks the save button, the function checks the events requirements schedule in the database based on the date and timestart and timeend that user inputs.
Since I really don’t know how in yiiframework I’ve used jquery and php hereunder;
in my: baseurl/js/script.js
/* dov: date of visit, tov: time of visit (start), tov_end: time of visit (end)*/
$(document).ready(function() {
$("#save").click(function() {
if ($("#dov").val() == "" || $("#tov").val() == "" || $("#tov_end").val() == "")
{
alert("Please complete the form");
}
else
{
$.post('../inc/validate.php', { dov : $("#dov").val(), tov : $("#tov").val(),
tov_end : $("#dov_end").val()}, function(data) {
document.getElementById("myDiv").innerHTML = data;
});
}
});
in my: baseurl/inc/validate.php
<?php
$dov = $_REQUEST[‘dov’];
$tov = $_REQUEST[‘tov’];
$tov_end = $_REQUEST[‘tov_end’];
function checkAvailability($dov,$tov,$tov_end){
sql = mysql_query("sql to check from data if it has conflicts");
... ;
return $availability;
}
if(isset($_REQUEST[‘dov’]){
?>
<script> alert(<?php echo $dov; ?>); </script>
<?php } ?>
My problem is it that the $.post seems not posting to validate.php, does anyone knows the answer? can you recommend were to put my checkAvailability() php functions and how to call it.
Thanks and GOD Bless.