0

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.

5 Answers 5

1

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

HTTP is stateless.

Sign up to request clarification or add additional context in comments.

1 Comment

I know it alex.How to get my js var value in nxt page.
0

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

1 Comment

Please consider learning AJAX. You would need to learn this anyway if you want to develop Web Applications.
0

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

8 Comments

@nick: <input type="hidden" value="document.write(a);" > but this is not working
@deree There is no JavaScript there. Use the value property of the input element.
@alex: What is document.write called as?I have used it in value only.Pls see my script correctly
Right, first of all you need to give your hidden field a name/ID so that your JS can reference it. Then you need to just set that value in the JS - document.getElementById(hiddenElementID).value = whateverYouWantItToBe
@Nick: Should i use u r script in next page or in this page only
|
0

If you use jQuery you can call something like:

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

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

1 Comment

I wrote a function it get i/p from prompt and stores it in a variable,now need to pass this value to next page.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.