...

View Full Version : passing parameters between 2 web pages



ingie001
12-17-2006, 06:38 PM
attached are 2 modules which are supposed to pass data between 2 web pages. The coding was supplied by to me by a web site and it does not work. I am not able to see why - can anyone help.
First module which I call 'pass1.html'

<html>
<head>
<title>pass</title>
</head>
<BODY>
<center>
<form type=get action="pass2.html">
<table border=1>
<tr>
<td>First Name:</td>
<td><input type=text name=firstname size=10></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type=text name=lastname size=10></td>
</tr>
<tr>
<td>Age:</td>
<td><input type=text name=age size=3></td>
</tr>
<tr>
<td colspan=2><input type=submit value="Submit!">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>

second module which I call 'pass2.html'

<html>
<head>
<title>pass</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
// End -->
</script>
</HEAD>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
firstname = unescape(params["firstname"]);
lastname = unescape(params["lastname"]);
age = unescape(params["age"]);
document.write("firstname = " + firstname + "<br>");
document.write("lastname = " + lastname + "<br>");
document.write("age = " + age + "<br>");
// End -->
</script>
</body>
</html>

Mr J
12-17-2006, 10:36 PM
Have a read of this example see if it helps

www.huntingground.freeserve.co.uk/scripts/passdata/formget1.htm



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum