I am using the following code:
<?php $id = $_GET['id']; echo $id; var java_id= <?php echo $id; ?> ; alert(java_id); </script>
The value doesn't alert. What is the mistake?
Thank you!
I am using the following code:
<?php $id = $_GET['id']; echo $id; var java_id= <?php echo $id; ?> ; alert(java_id); </script>
The value doesn't alert. What is the mistake?
Thank you!
Maybe try just this:
<script>
// More java code here I am guessing from your example...
var java_id= <?php echo $_GET['id']; ?> ;
alert(java_id);
</script>
if you are writing your code on a .php file then javascript variables need to be enclosed within tag and there you can use php variables directly by assinging variable in your case like var java_id= ""; inside script tag... however if you are trying to directly access php variable in your .js file then you need to create global javascript variable before including your .js file...