Calling javascript variables from a separate HTML/php file -


i have separate javascript file(buy.js) html file(pay.php) html file posts once form submitted. however, there javascript variables in pay.php outside scope of form need call in separate javascript file (buy.js). possible do?

this snippet of javascript need access in html file (buy.js):

  var planterm = term; 

this javascript in html need separate javascript file access (pay.php):

var term = 0; var price = 0;  function updateprice(e) {      price = parsefloat(select.value);     if (price == select.options[1].value){         term = 12;     } else if (price == select.options[2].value) {         term = 1;     } } 

here pastie of code.

using php can (using include() function):

include("file.php"); 

so, example goes,

the js_include.php file:

<html> <body>   <script>     var jsvar = "this external js var.";   </script> </body> </html> 

the index.php

<html> <body>     <?php     include("js_include.php");     ?>      <script>     document.write(jsvar);     </script> </body> </html> 

but of course if .php file remote directory, cannot.

sources:

include() function: http://www.php.net/manual/en/function.include.php


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -