How to combine PHP and JavaScript?

How to combine PHP and Java Script

Suppose you need to transfer the value of PHP variables to the JavaScript function. Let’s assign values to two variables in the following way:


$mess = "Your query is being processed..."; 
$lang = "EN";


Now let’s write the following in the HTML-code:

<form method="POST" 
	action="#" enctype="multipart/form-data" 
	name="dosearch" id="dosearch" onSubmit="return false"

<input type="text" size="70" name="search" id="search">

<input style="width:110px"  name="button" type="button" value="Search"  
'<?php echo $mess; ?>','<?php echo $lang; ?>')"></p>


At the opening of the page, vaues of variables $mess and $lang will be written in HTML-code and, when pressing the button of the form, they will be transferred to the JavaScript function.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *