pass php variable to JS function

Hello
I have a big problem with pass php variable to JS function

PHP

[CODE]<?
[COLOR=“Red”]$codid[/COLOR]=$_GET[“cid”];

echo "

"; ?> [/CODE]

JS FUNCTION

function [COLOR="Blue"]CSelect()[/COLOR]
			{
				var
					$http,
					$self = arguments.callee;


				if (window.XMLHttpRequest) {
					$http = new XMLHttpRequest();
				} else if (window.ActiveXObject) {
					try {
						$http = new ActiveXObject('Msxml2.XMLHTTP');
					} catch(e) {
						$http = new ActiveXObject('Microsoft.XMLHTTP');
					}
				}

				if ($http) {
					$http.onreadystatechange = function()
					{
						if (/4|^complete$/.test($http.readyState)) {
							document.getElementById('ReloadThis').innerHTML = $http.responseText;
							setTimeout(function(){$self();}, 10);
						}
					};
					$http.open('GET', 'linii_c/select.php'+'?cod='+'[COLOR="Red"]PHP VARIABLE[/COLOR]', true);
					$http.send(null);
				}

			}

How can i add a variable in JS function?

Thank you!

Hi there,

Try this approach:
[php]echo "

";[/php]

JS:

function CSelect(codid) { var $http, $self = arguments.callee; ...... ...... }; $http.open('GET', 'linii_c/select.php?cod='+codid, true); $http.send(null);

Don’t work :frowning:

Sponsor our Newsletter | Privacy Policy | Terms of Service