-4

the javascript code as below...how can I pass x to php?And there is not any button.

    function f(){
    var x = document.getElementById("point").innerHTML;
    }

And if I pass x to the php file,how can I receive it?

wind910037
  • 21
  • 5

3 Answers3

1

Try this one,

function f(){
    var x = document.getElementById("point").innerHTML;
    window.location.href = 'page.php?point='+x;
}

And in page page.php try this,

$point = $_GET["point"];
Jithin Varghese
  • 2,018
  • 3
  • 29
  • 56
0

The only to do so is by making an ajax request. For more info on making an ajax request, refer this

Sanchit
  • 541
  • 2
  • 18
0

Try This out:

function myFunction() {var javascriptVariable =document.getElementById("point").innerHTML;window.location.href = "myphpfile.php?name=" + javascriptVariable; } 

On your myphpfile.php you can use $_GET['name'] after your javascript was executed.

CodeConstruct
  • 290
  • 3
  • 17