How to call a variable that is in another file?

-1

I have a "Y.php" file that returns in one of the inputs, the resulting calculation of other inputs inside this same file, I do this using Jquery and it is running 100%.

However, I would like to use the result of this calculation that is stored in variable "X" in another input contained in the "Z.php" file. That is, I want to use the value of this input (contained in "Z.php") as a result of another input contained in the file "Y.php".

How do I do this with JavaScript?

require ('apNaoCirculantes.php'); //arquivo onde está a input na qual desejo pegar o valor
            var totaldeparred; // é o variável da input
            var campo16; // já estou no arquivo Z.PHP
            campo16 === totaldeparred;
            $("#depreciacao1").maskMoney('mask', totaldeparred); //minha input #depreciacao1 recebe o valor contido em totaldeparred

Is that it?

    
asked by anonymous 14.10.2017 / 00:37

1 answer

2

Make an include of the Y.php file at the beginning of <body> Z.php page:

<?php require('Y.php'); ?>

Then get the value of <input> by id (if the input has a desired id ) coming from the Y.php page and put it in <input> of the page Z.php:

<script>
document.getElementById("id_do_input_em_Z.php").value = document.getElementById("id_do_input_em_Y.php").value;
</script>
    
14.10.2017 / 01:19