469,575 Members | 1,680 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

javascript replacing the spaces with a 'plus' sign in a passed value

My end goal is to have a script that takes user input from one pageA, submits to pageB which then displays the parameter values entered on PageA. My problem is that the values are being displayed with any included spaces being replaced with the plus sign. Any help would be appreciated.

pageA code:

<form type="get" action="pageB.html" target="new" onSubmit="window.open('','new','width=450,height=3 00,status=yes,resizable=yes,scrollbars=yes')">
spoke with: <input name="spokeWith" type="text" value="" size="32">
phone number: <input type="text" name="phoneNumber" size="32">
email address: <input type="text" name="emailAddress" size="32">
other: <input type="text" name="other" size="32">
<input name="submit" type="submit" value="generate comments!">
pageB code:

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();

<title>generated order comment:</title>

spokeWith = unescape(params["spokeWith"]);
phoneNumber = unescape(params["phoneNumber"]);
emailAddress = unescape(params["emailAddress"]);
other = unescape(params["other"]);

document.write("Spoke With: " + spokeWith + " //" + "<br>");
document.write("Phone Number: " + phoneNumber + " //" + "<br>");
document.write("Email Adderss: " + emailAddress + " //" + "<br>");
document.write("Other: " + other + " //" + "<br>");

Apr 28 '06 #1
1 6567
16,027 Expert Mod 8TB
Use decodeURIComponent().
Mar 24 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Peter Smith | last post: by
10 posts views Thread by Philipp Lenssen | last post: by
1 post views Thread by James Howe | last post: by
7 posts views Thread by Richard Trahan | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.