dlg0351
03-19-2005, 01:31 AM
I have a simple form that passes a string from Page1 to Page2.
Everything is working fine except that if the input has spaces, the spaces are displayed on Page2 as '+' signs.
How can I modify the code to make the spaces not display as '+' signs?
Page1
<html>
<head>
<title></title>
</head>
<body>
<form name="myform" method="get" action="page2.html">
<input name="input1">
<input type="submit">
</form>
</body>
</html>
Page2
<html>
<head>
<title></title>
<script LANGUAGE="JavaScript">
<!--
function decodeSearchString() {
var nameValue = new Array();
var searchStr = unescape(location.search.substring(1));
if (searchStr) {
var formElement = searchStr.split("&");
var tmpArray = new Array();
for (k = 0; k < formElement.length; k++) {
tmpArray = formElement[k].split("=");
nameValue[tmpArray[0]] = tmpArray[1];
}
}
return nameValue
}
var srchData = decodeSearchString();
//-->
</SCRIPT>
</head>
<body>
<script>document.write(srchData.input1);</script>
</body>
</html>
Everything is working fine except that if the input has spaces, the spaces are displayed on Page2 as '+' signs.
How can I modify the code to make the spaces not display as '+' signs?
Page1
<html>
<head>
<title></title>
</head>
<body>
<form name="myform" method="get" action="page2.html">
<input name="input1">
<input type="submit">
</form>
</body>
</html>
Page2
<html>
<head>
<title></title>
<script LANGUAGE="JavaScript">
<!--
function decodeSearchString() {
var nameValue = new Array();
var searchStr = unescape(location.search.substring(1));
if (searchStr) {
var formElement = searchStr.split("&");
var tmpArray = new Array();
for (k = 0; k < formElement.length; k++) {
tmpArray = formElement[k].split("=");
nameValue[tmpArray[0]] = tmpArray[1];
}
}
return nameValue
}
var srchData = decodeSearchString();
//-->
</SCRIPT>
</head>
<body>
<script>document.write(srchData.input1);</script>
</body>
</html>