Hi,

how do i pass the variables color, city and food to the mypage.php? I am able to get 'name' and 'age'. I want tto be able to pass all the variables mentioned in the script.

<script type = "text/javascript" src="mypage.php?name=test&age=23">

var color = "red";
var city = "london";
var food = "seafood";

</script>

Thanks a million!!!

Member Avatar for diafol

You need to send the data either via Ajax or by redirect or by form submission. You can't pass off data to php as once the page reaches the client it's done and dusted. It won't react to interactive elements / js on your page. You have to make a new call to the server.

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.