...

View Full Version : Query String Question



dlg0351
03-19-2005, 02: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>

hemebond
03-19-2005, 03:36 AM
string = string.replace(/\+/g, ' ');

dlg0351
03-19-2005, 04:24 AM
Where do i out that in the code?

hemebond
03-19-2005, 04:59 AM
Wherever you want the '+' character replaced with the ' ' character.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum