By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,914 Members | 563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,914 IT Pros & Developers. It's quick & easy.

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

P: 1
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="'','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
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 16,027
Use decodeURIComponent().
Mar 24 '08 #2

Post your reply

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