Nov Esk Eduard Nov Esk Eduard - 7 months ago 9
Javascript Question

token illegal; PHP inside javacript code

i use php in my javascript code to print a javascript line but i have an error, what am I doing wrong?? help me please

<?php if (isset($_GET['dateSelected'])) {

echo '$("#eliminarCitaBtn").attr("href", "index.php/agenda/eliminarCita/"+event.cita_id+"/?agendaId='.$_GET["agendaId"].'&dateSelected='.$_GET["dateSelected"].');';

}else{
echo "$('#eliminarCitaBtn').attr('href', 'index.php/agenda/eliminarCita/'+event.cita_id+'/?agendaId=".$_GET['agendaId'].");";

}?>



Answer

You are't closing the quotes at the end of either attr().

There '");'; and there "');";