473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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

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:

[HTML]<html>
<body>
<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!">
</form>
</body>
</html>
[/HTML]
pageB code:

[HTML]<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
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();
</script>

<title>generated order comment:</title>
</head>
<body>

<SCRIPT LANGUAGE="JavaScript">
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>");
</script>

</body>
</html>[/HTML]
Apr 28 '06 #1
1 6754
acoder
16,027 Expert Mod 8TB
Use decodeURIComponent().
Mar 24 '08 #2

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

Similar topics

1
by: Peter Smith | last post by:
Hi I am writing a message board, and the text is entered in a text box and outputted in HTML. How can I keep the spaces formatting (ie use &nbsp;'s) in the html output?? I use the standard...
10
by: Philipp Lenssen | last post by:
I know it's terribly incorrect (well I think I know) to use something like <a href="bla.php?title=hello world">Hello World</a> but can I safely do this? I have an Apache Linux server with...
1
by: James Howe | last post by:
I'm working on a web application which needs to submit information to the server via a URL string. The URL can contain values retrieved from form input fields. I'm using the escape function to...
7
by: Richard Trahan | last post by:
I need a javascript function to hex-encode a plus sign so I can pass the plus sign as an argument in a GET request. escape() and encodeURI() don't do it (and probably shouldn't, because '+' is a...
0
by: Emil Georgiev | last post by:
Hell I have a Web Custom Control project in ASP.NET. I'm using a subclassing technique to add functionality in HyperLink web server control. I want to create a property "BrowserWindow" of my...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
2
by: David | last post by:
Sent this to alt.php a couple of days back, but doesn't look like I'll get an answer, so trying here. I'm trying to convert a script to use friendly URLs, I've done this before, but my PHP...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.