dferee
dferee

Reputation: 11

passing javascript value to another page

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 and 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.

Upvotes: 0

Views: 924

Answers (5)

mateusza
mateusza

Reputation: 5743

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

Upvotes: 0

alex
alex

Reputation: 490143

Please understand JavaScript is ran on the client machine, and PHP on the server.

HTTP is stateless.

Upvotes: 1

Petah
Petah

Reputation: 46040

If you use jQuery you can call something like:

$.post("test.php", { name: "John", time: "2pm" } );

See http://api.jquery.com/jQuery.post/

Upvotes: 0

Nick
Nick

Reputation: 2468

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).

Upvotes: 0

Shamim Hafiz - MSFT
Shamim Hafiz - MSFT

Reputation: 22064

You have to use AJAX. Are you familiar with AJAX?

Upvotes: 0

Related Questions