Jump to content

php & JavaScript


aoghsshebron
 Share

Recommended Posts

If you're using an external Js file you could do something like this:

<?header('Content-type: text/js');?>var abc = <?=abc?>

If not, you can just echo the vars bitween you're Js code, like Html.

Link to comment
Share on other sites

If you're using an external Js file you could do something like this:
<?header('Content-type: text/js');?>var abc = <?=abc?>

If not, you can just echo the vars bitween you're Js code, like Html.

if <OPTION value=$sFullname>($sFullname is php value)the result is "$sFullname "cannot read the the value~~how can i pass it in http option
Link to comment
Share on other sites

Put the php variable in a hidden html inputuse javascript to access the inputthis works, save as whatever.php

<?php ini_set ('display_errors', 1);error_reporting (E_ALL & ~E_NOTICE);$val="hello";print"Value in PHP: $val";print'<input type="hidden" id="secret" value="'.  $val. '"  />';?><script> var getVal=document.getElementById('secret').value; document.write("<br />Value in Javascript: "+getVal);</script>

Link to comment
Share on other sites

Put the php variable in a hidden html inputuse javascript to access the inputthis works, save as whatever.php
<?php ini_set ('display_errors', 1);error_reporting (E_ALL & ~E_NOTICE);$val="hello";print"Value in PHP: $val";print'<input type="hidden" id="secret" value="'.  $val. '"  />';?><script> var getVal=document.getElementById('secret').value; document.write("<br />Value in Javascript: "+getVal);</script>

thank a lot^^i got it
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...