Skip to content Skip to sidebar Skip to footer

Passing A String Variable From Php To A Js Function

I was looking for a way to pass a string(variable saved in a form of $x) from php to Java Script and I found so many codes to solve that, but my question is : does those strings ha

Solution 1:

As the others have said, all we can say is that you are doing something wrong. You can place PHP variable values, strings or otherwise, wherever you want in your JavaScript code, since PHP is server-side and can do whatever you like on the client side.

Solution 2:

This will help you to solved the issue of passing string variable value by calling the javascript function within php scrpt. :)

<?php$testStrFileName = "test.jpg";

$file_name = "<script>". $testStrFileName ."</script>";

//<sample tags/>echo'<a href="javascript:deleteGalleryImage('.$file_name.');">Delete</a>';

?>

Post a Comment for "Passing A String Variable From Php To A Js Function"