I am trying to passing javascript variable value to another page and retrieve here into a php variable
Using function i made a pop up to appear and store it to a java script variable so now how do i pass it another page an开发者_StackOverflowd i do have some text box values but i get this ,i use action and give page name in it.I need both text box value and prompt value in another page.
Please understand JavaScript is ran on the client machine, and PHP on the server.
HTTP is stateless.
You have to use AJAX. Are you familiar with AJAX?
Use JavaScript to dynamically add hidden form fields into your form and set the value (alternatively just create the hidden fields in the php output with no value and just use JS to set it).
If you use jQuery you can call something like:
$.post("test.php", { name: "John", time: "2pm" } );
See http://api.jquery.com/jQuery.post/
Using JS you can put a variable into cookie:
document.cookie = 'var1=VALUE1'
Then read it on the other page.
Or you can append #var1=value1
to URL, then read it on the other page using
top.location.hash
精彩评论