and this value is accessed in the php script
as
$newvalue = $_REQUEST['id3'];
or
$newvalue = $_GET['id3'];
Main Topics
Browse All TopicsRecently I've asked a question about reloading page and I've got an answer which have the following code
document.location.href="<?
It let me to keep a variable "id2" after reloading the page.
actually I am not quite understand the meaning of this piece of code, now I would like to store one more variable after reloading the page. It is just a variable declared in my php page, can I do this?
thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
@minutes
you have to differentiate between javascript and php. If you want to load a variable $test in the php page that the javascript link is going to it has to look like as follows:
document.location.href="<?
in the php-page you get:
$id2 = $_GET['id2'] (as venkateshwarr wrote)
$test = $_GET['test'] (will get the value == someValue)
//jan
Sessions are a more convenient way to deal with this:
<?php
session_start(); // call this at the beginning of your script
// this code saves the values (you'd use this at the end of your script)
$_SESSION['obj1'] = serialize($obj1);
$_SESSION['obj2'] = serialize($obj2);
// this code gets the values
$obj1 = unserialize($_SESSION['obj
$obj2 = unserialize($_SESSION['obj
// ... etc
?>
$_SESSION is an array where you can store arbitrary data that will persist between sessions. See http://www.php.net/session
serialize() turns a PHP structure (such as an array or even an object) into a string. unserialize() turns a string obtained with serialize() back into the PHP structure it was before it was serialized.
Sorry, but I just try to implement in this code but it doesn't work.
<html>
<head>
<title>Main page for CSM</title>
</head>
<script>
function reload(form)
{
document.location.href="<?
}
</script>
<body>
<?php
$formvalue = "testing";
$scriptvalue1 = $_GET['scriptvalue'];
echo $scriptvalue1;
?>
<select name='select' onChange='reload(this)'>
<option>a</option>
<option>b</option>
</select>
</body>
</html>
You have to give a value to $formvalue above the
document.location.href="<?
line.
<html>
<head>
<title>Main page for CSM</title>
</head>
<script>
<?php $formvalue="testing"; ?>
function reload(form)
{
document.location.href="<?
}
</script>
<body>
<?php
$scriptvalue1 = $_GET['scriptvalue'];
echo $scriptvalue1;
?>
<select name='select' onChange='reload(this)'>
<option>a</option>
<option>b</option>
</select>
</body>
</html>
Business Accounts
Answer for Membership
by: venkateshwarrPosted on 2004-04-19 at 11:51:38ID: 10862431
Here
=$PHP_SELF ?>?id2="+o bj.value+" &id3="+new value;
$PHP_SELF is the name of the script file. If you add variable value pairs at the end of the page and the reloads, the values are sent to the page using get method.
to add one more variable use this.
document.location.href="<?