How to add javascript to php page

what is the right way too add javascript to php page. i have the code with html and it work fin.

<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" href="./js/jquery.calendars.picker.css">
<script src=""></script>
<script src="./js/jquery.plugin.js"></script>
<script src="./js/jquery.calendars.js"></script>
<script src="./js/"></script>
<script src="./js/jquery.calendars.picker.js"></script>
<!--<script src="jquery.calendars.picker.ext.js"></script><!-- Include for ThemeRoller styling -->
<script src="./js/jquery.calendars.ummalqura.js"></script>
$(function() {

	var calendar = $.calendars.instance('ummalqura');
	$('#popupDatepicker').calendarsPicker({calendar: calendar});

function showDate(date) {
	alert('The date chosen is ' + date);

<p><input type="text" id="popupDatepicker"></p>


it is very important for me to work without html tag.

this is the Source link:

Javascript and PHP operate at completely opposite runtimes.

PHP script is evaluated at the server; the resulting HTML/JS is sent to the browser.
The browser receives the HTML/JS and then evaluates Javascript locally.

So, to add Javascript to a PHP page… as far as the PHP engine is concerned, the javascript is the same as HTML. Anything outside of the PHP tags is ignored by the PHP engine.

1 Like

Hi @ebrahim

What does this line in your question mean?

You need to escape your quotes with backslashes:
echo ‘$(function(){$('div#subemail').fadeIn('slow');});’;

The problem is you’re opening a string with the first ', and closing it at 'div#… rather than closing it at the end of the line. Most languages use a backslash to denote a quote which is part of the string, rather than terminating the string.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.