-2

Im trying to rerun an php include after I changed it with js

The php file ist connectiong to an db and only gets the data which is requestet with the get variable in the url

<output id = "ulid">
   <?php include ("http://localhost/Test/testx.php?testget=HRA"); ?>
</output>

And then i change the file with innerHTML from output (after an onchange event from)

    var skala = document.getElementById("skalaRock").value;     
    var y =  '&lt;\?php include ("http:\/\/localhost\/Test\testx.php?skala='+skala+'"); ?&gt;';
    document.getElementById("ulid").innerHTML = y;

The output is '<?php include ("http://localhost/Test/testx.php?skala='+skala+'"); ?>' that is the right file, but how can I get the file to execute? And dont just show the php command?

EdgarJ
  • 3
  • 1

3 Answers3

1

You can use .load method of jQuery to load the php file after the change event Below is the given link of jQuery documentation of load() https://api.jquery.com/load/

1

PHP runs on the service side. and the page runs on the client side.

you cant change the code on the servie side from the client side.

Wellen zhong
  • 96
  • 1
  • 5
0

When you do soemthing with JavaScript in response to an onchage event, this happens on client side, in the browser.

If you want any php code to be executed (on server side) from there, you will have to send an Ajax request to the server.

C.B.
  • 208
  • 2
  • 7