Is it possible to pass the javascript varible from one php page to another php page. what is the syntax we use.

Recommended Answers

All 4 Replies

you can pass the javascript variables to another page:

<script type="text/javascript">
var x="one";
window.location.href = "yourpage.php?var=" + x;
</script>

yourpage.php

$var=$_GET['var'];
echo $var;

thanks for the above code how to pass more than one variable to the same page using the single link

just add it to the link like this:

<script type="text/javascript">
    var x="one";
    var y="one";
window.location.href = "yourpage.php?var=" + x + "&var2=" + y;

      </script>

then:

$var=$_GET['var'];
   $var2=$_GET['var2'];
      
    echo $var."<br>";
   echo $var2;

thank a lot for ur help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.