473,385 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

passing vars

I want to pass a variable from one page(in javascript) to a second page(in
php,) what is the syntax in both lanuages to do such?

Thx in advance, Terry
Jul 20 '05 #1
2 1923

"Terry A. Haimann" <te***@yngstr.oldboy.com> schreef in bericht
news:pa****************************@yngstr.oldboy. com...
I want to pass a variable from one page(in javascript) to a second page(in php,) what is the syntax in both lanuages to do such?

Thx in advance, Terry


Hi,

Put the values in hidden inputs on a form and post it to your php page.
The posted inputs will be available in php as variables.

<form action="myFile.php" method="post" name="myForm">
<input type="hidden" name="myVar" value="">
</form>
<script type="text/javascript">
document.forms["myForm"].elements["myVar"].value="Hello world"
document.forms["myForm"].submit()
<script>

------------------------

myFile.php:

echo "Received value: ".$myVar ;
hth Fred
Jul 20 '05 #2
Thx, I had scoured the book stores, but hadn't figured it out. Last night
I was back at b&n("to feed my mocha habit") when I came across Query
Strings. I added the code and they seem to work.

On Thu, 11 Sep 2003 09:03:47 +0200, Fred Serry wrote:

"Terry A. Haimann" <te***@yngstr.oldboy.com> schreef in bericht
news:pa****************************@yngstr.oldboy. com...
I want to pass a variable from one page(in javascript) to a second

page(in
php,) what is the syntax in both lanuages to do such?

Thx in advance, Terry


Hi,

Put the values in hidden inputs on a form and post it to your php page.
The posted inputs will be available in php as variables.

<form action="myFile.php" method="post" name="myForm">
<input type="hidden" name="myVar" value="">
</form>
<script type="text/javascript">
document.forms["myForm"].elements["myVar"].value="Hello world"
document.forms["myForm"].submit()
<script>

------------------------

myFile.php:

echo "Received value: ".$myVar ;
hth Fred


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Richard Ragon | last post by:
Hows does the passing variables from page to page work? Specifically, when you type in a URL like: http://www.someurl.com/test.php?someVar=20 How does the next page get, and use the variable?...
3
by: Pjotr Wedersteers | last post by:
Hello again, I have now several consecutive forms in my site which nicely pass variables in POST, so they won't show up in the header. Now I have a page people reach after submitting all kinds...
5
by: Steve | last post by:
Hi, I currently have a problem passing a variable value from one page to another. Once a form submit button is pressed java pops up a window and displays some information. The problem being is...
2
by: Jeff | last post by:
....still new to .net 2005 using VB. Do I understand correctly that the value of a session variable is actually stored in the server's ram, but relies on the asp.net session ID cookie that...
2
by: Bob Bruyn | last post by:
I've recently installed Apache 2 and php 5.2 on my WIndows XP machine. Everything is up and running. I'm passing some vars via the URL. It works fine online:...
4
by: pcaisse | last post by:
I'm having issues sharing global variables with Explorer. This problem probably has a simple answer (as with most newbie questions). The script.pl file: #!/usr/bin/perl -w use strict; use...
2
Magdelana
by: Magdelana | last post by:
Hello I have a startEditing function that has to "build" a href call to another function and pass 2 vars (a,b) They are in this function ( I can print them out), but I get an "a is not defined"...
5
by: Ross | last post by:
Forgive my newbieness - I want to refer to some variables and indirectly alter them. Not sure if this is as easy in Python as it is in C. Say I have three vars: oats, corn, barley I add them...
0
by: rjgulick | last post by:
Hey Everyone, I am trying to pass a var(folder_name) from my main swf to a swf that i am loaded. Here is what i have so far. I know I am missing something I just dont know what. Any help would be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.