开发者

passing javascript value to another page

开发者 https://www.devze.com 2023-02-08 11:44 出处:网络
I am trying to passing javascript variable value to another page and retrieve here into a php variable

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
0

精彩评论

暂无评论...
验证码 换一张
取 消