Ranjith Ranjith - 2 months ago 10
Javascript Question

Get Javascript Variable to assign php vaiable

I am Trying to JavaScript Variable to assign PHP Variable and my Value to Alert but Getting on error
the output as
"; alert(simple);



var p1sds = "My Custom String";
<?php
$dsfd = "<script>document.writeln(p1sds)</script>";
?>
var simple = "<?php echo $dsfd ;?>";
alert(simple);

</script>

Answer

Hi I am just changed the following Thinks its Working

var p1sds = "My Custom String";
 document.cookie='p1sds='+p1sds; 

<?php
if (isset($_COOKIE["p1sds"])) {
 $asdas= $_COOKIE["p1sds"]; 
}
?>
   var simple = "<?php echo $asdas ;?>";
      alert(simple);

</script>
Comments