...

View Full Version : Passing values one page to another



radsat
05-14-2007, 09:04 PM
Hi

I have an index page which has link to another page(say pageA). In the src of the link, i pass the value as pageA.html?msg=msgValue.

pageA.html is like this,

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" SRC="script.js">
</SCRIPT>
<title>Global Electronic Compound Aggregation</title>
<!-- header info used to contain extra information about
this document, not displayed on the page -->
<link rel="stylesheet"
type="text/css" href="font.css" />
</head>
<body>
<FRAMESET rows="15%,89%" cols="*">
<FRAME id="title" SRC="title.html?site=US" name="title">
<FRAMESET rows="*" cols="13%,64%,23%">
<FRAME id="menu" SRC="menu.html?site=US">
<FRAME id="about" SRC="detail.html?site=US" name="detail">
<FRAME id="quickLaunch" SRC="launch.html?site=US">
</FRAMESET>
</FRAMESET>
<body> </body>
</html>my question is, how do I attach the msg=msgValue from the index page to all the other pages in the frameset. I want something like,

title.html?site=US&msg=msgValue
menu.html?site=US&msg=msgValue
detail.html?site=US&msg=msgValue
launch.html?site=US&msg=msgValue

I tried writing a javascript on the onLoad() of the Frameset but it does not work.

My Java script looked like,

Code:
function appendSiteEnv(hiddenValue)
{
document.getElementById('title').setAttribute('href','title.html.html?site='+hiddenValue+'&env='+get Env());
document.getElementById('menu').setAttribute('href','menu.html?site='+hiddenValue+'&env='+getEnv());
document.getElementById('about').setAttribute('href','detail.html?site='+hiddenValue+'&env='+getEnv( ));
document.getElementById('launch').setAttribute('href','quickLaunch.html?site='+hiddenValue+'&env='+g etEnv());
}

function getEnv()
{
env="";
var arrArgs = location.search.substring(1).split("&");
if(arrArgs.length>1)
env=arrArgs[1].substring(arrArgs[1].indexOf("=")+1);
else if(arrArgs.length==1)
env=arrArgs[0].substring(arrArgs[0].indexOf("=")+1);
return env;
}
Any help is greatly appreciated

glenngv
05-15-2007, 01:37 AM
Are you not using a server-side language like PHP, ASP, JSP, etc? It's very easily done using a server-side language and the most recommended solution as it cannot be disabled like Javascript.

If you really don't use a server-side language, then you can do it like this:

<html>
<head>
<SCRIPT LANGUAGE="JavaScript" SRC="script.js">
</SCRIPT>
<script type="text/javascript">
function init(){
document.getElementById("title").src = "title.html?site=US&env=" + getEnv();
document.getElementById("menu").src = "menu.html?site=US&env=" + getEnv();
document.getElementById("about").src = "detail.html?site=US&env=" + getEnv();
document.getElementById("quickLaunch").src = "tlaunch.html?site=US&env=" + getEnv();
}

function getEnv()
{
var env="";
var arrArgs = location.search.substring(1).split("&");
if(arrArgs.length>1)
env=arrArgs[1].substring(arrArgs[1].indexOf("=")+1);
else if(arrArgs.length==1)
env=arrArgs[0].substring(arrArgs[0].indexOf("=")+1);
return env;
}

window.onload = init;
</script>
<title>Global Electronic Compound Aggregation</title>
<!-- header info used to contain extra information about
this document, not displayed on the page -->
<link rel="stylesheet"
type="text/css" href="font.css" />
</head>
<FRAMESET rows="15%,89%" cols="*">
<FRAME id="title" SRC="about:blank" name="title">
<FRAMESET rows="*" cols="13%,64%,23%">
<FRAME id="menu" SRC="about:blank">
<FRAME id="about" SRC="about:blank" name="detail">
<FRAME id="quickLaunch" SRC="about:blank">
</FRAMESET>
</FRAMESET>
</html>

radsat
05-15-2007, 06:04 PM
Thanks Glenn, it works great.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum