mardi 27 juin 2017

include php function to javascript

in test.php file

<html>
<head>
  <script type="text/javascript" src="java_script.js"></script>
</head>
<body>

Name: <input type="text" id="myText" value="Mickey">

<button onclick="myFunction()">Click Me</button>

</body>
</html>

in java_script.js

function myFunction() {
    var user_name = 'Hellow World';
    document.getElementById("myText").value = user_name;
}

How to use function or variable from php_test.php

in php_test.php

  <?php
      $phpVar = 'Hello World';
      echo $phpVar;
  ?>

Thank you everyone i'm not good in English, You can correct me :)




Aucun commentaire:

Enregistrer un commentaire