I want to have some javascript execute based on some php if statement, but I can't get the quotes around my link correct .. In console it shows that a ) is missing from the following line. I'm sure I messed up the quotes, it was correct when I just had it javascript, but now mixing with echo I can't get it. I'm using single quotes around the whole thing and doubles inside. The rest is working, please take a look and help me fix this line. Thanks!
$(this).append("<a href=""index.php?patient=test&a="".""appointment_nums[count]""."">Schedule Appointment </a>");
if ($mode== 'view' && $action==''){
echo '<script >
$(document).ready(function(e){
$("body").click(function(event) {
redirect = $(event.target).context.getAttribute("href");
});
checkColumns();
});
function checkColumns(){
count=0;
appointment_nums = [];
$(".mgrid_table > tbody > tr").each(function() {
appointment_nums.push($(this).find("td").eq(3).find("label").html());
appointment_nums = appointment_nums.filter(function(n){ return n != undefined });
});
appointments = appointment_nums.length;
appendColumns();
}
function appendColumns(){
function ajax() {
return $.ajax({
type:"post",
url: "../testrequest.php",
data : {appointment_nums:appointment_nums},
dataType:"json",
});
};
ajax().done(function(result){
$("table:nth-of-type(2) > tbody > tr > td:nth-of-type(2)").each(function() {
if($(this).children().length < 1){
if (result[count] == false){
$(this).append("<a href=""index.php?patient=test&a="".""appointment_nums[count]""."">Schedule Appointment </a>");
}else{
$(this).append("<span>Waiting For Doctor to Schedule</span>");
}
}
count = count + 1 ;
});
});
}
</script>';