Javascript variable into php variable

You can do it by setting url variables or session variables.  
one way to do this is to pass the url like this

<SCRIPT LANGUAGE='JavaScript'>
<!-- //
var name="Dave";
var number=100;
document.write('<a href="another_page.php?name='+name+'&number='+number+'">another page</a>');
// -->
</SCRIPT>
from http://www.iwdp.co.uk/pfv/javascript_to_php_PFV.htm

then get the variables using php

<?php $var1 = $_GET['name']; $var2= $_GET['number']; ?>



you can do this via GET, POST, SESSION

You could do this all on the same page if you wanted to by calling a javascript function that sets these variables and then php gets them.

Comments

Popular posts from this blog

உடல் அறிகுறிகள், வலிகள் மற்றும் அவற்றின் சிகிச்சைகள்: வீட்டு சிகிச்சைகள் மற்றும் அக்குபிரஷர் புள்ளிகள்

MySQL table and want to build a XML file with it in order to make a RSS feed.

REST / AJAX calls from within a Jaggery script