Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

passing a php variable to java


monito

Recommended Posts

I'm trying to pass a var_name from php to java, but I cannot get it to work...

 

<?php

 

$var_name = "some test <br />";

print $var_name;

?>

<script type="text/javascript">

document.writeln('

<?php

$var_name;

?>

');

</script>

 

 

Thanks,

 

Monito

Link to comment
Share on other sites

You will never get this to work. JavaScript (not Java - the two are *very* different!!) is a client-side scripting language (executed by the browser). PHP is a server-side language (executed by the webserver). You can use PHP to *populate* Javascript variables - but not to pass them. Here's an example:

 

<?php

$var_name = "some test <br />";

print $var_name;

?>

<script type="text/javascript">

document.writeln('<?php echo $var_name;?>');

</script>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...