473,387 Members | 1,669 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,387 software developers and data experts.

Question mark is creating line break

Hello All,

After I submit a form it goes to a post page where I have a javascript
that creates one variable that has all of the element names from the
form listed out like so:

var1=var1&var2=var2&var3=var3

and so on...

the problem is when i try to add a question mark in front of this
variable its adding a line break like so:

?
var1=var1&var2=var2&var3=var3

Here is the Javascirpt that gets each element name from the previous
form just submitted and puts it into one variable with the '=' and '&'
symbols:

var myForm = parent.document.forms.<CFOUTPUT>#FORM_NAME#</CFOUTPUT>;
var elements = ""
var character = ""
for (i = 0; i < myForm.elements.length; i++) {
if (i 0) {
elements = elements + "&" + myForm.elements[i].name + "=#" +
myForm.elements[i].name + "#";
}else{
elements = "?" + myForm.elements[i].name + "=#" +
myForm.elements[i].name + "#";
}
}
What Im trying to do with the end result is load it into a Ajax loader
to refresh part of a page like so:

var ajaxvar = "/admin/users/users.cfm" + elements;
parent.ajaxLoader(ajaxvar,'loader');

Any help would be great!

Thanks.
________________________
w. http://www.spymed.com

Sep 8 '06 #1
1 2461
Agent Michael Scarn wrote:
After I submit a form it goes to a post page where I have a javascript
that creates one variable that has all of the element names from the
form listed out like so:
var1=var1&var2=var2&var3=var3
and so on...

the problem is when i try to add a question mark in front of this
variable its adding a line break like so:

?
var1=var1&var2=var2&var3=var3

Here is the Javascirpt that gets each element name from the previous
form just submitted and puts it into one variable with the '=' and '&'
symbols:

var myForm = parent.document.forms.<CFOUTPUT>#FORM_NAME#</CFOUTPUT>;
That is no javascript. I suppose it's coming from your server language
that generates the js.
var elements = ""
var character = ""
for (i = 0; i < myForm.elements.length; i++) {
if (i 0) {
elements = elements + "&" + myForm.elements[i].name + "=#" +
myForm.elements[i].name + "#";
}else{
elements = "?" + myForm.elements[i].name + "=#" +
myForm.elements[i].name + "#";
}
}
I can't simulate your result on WinXP IE 6.0.29 and FF 1.0.4. The code
appears to work fine here. I believe it should have something to do
with where you say

var myForm = parent.document.forms.<CFOUTPUT>...

where current script takes its data from parent. Sorry for mentioning
the obvious, but make sure your first element name doesn't start with a
line end.

You could use a regular expression to replace 'question mark followed
by \n' to 'question mark' in the beginning of a string:

alert ( '?\nSOMETHING'.replace(/^\?\n/,'?') );

But there is another problem. You should make sure to escape your
element names/values before compiling your query string:

alert ( escape('thiscontains?and&and=') );

Hope this helps,

--
Bart

Sep 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dan Jones | last post by:
Hello, I'm trying to figure out how to get bit operators to work on a binary string. This is what I'm trying to do: list(frame) #where frame is a binary string y = frame << 8 It gives me a...
11
by: Hello | last post by:
Hello, I am a self-taught home developer: Question: As it seems, most CSS people like to use DIVs as a division between styles. So, they would have a style for a div tag that would hold some...
2
by: fb | last post by:
Hi everyone. I have the following code. It was a question out of C++ how to program. I get a warning about "possible unreachable code" in the RunCode() function, but I don't see any problem with...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
55
by: Steve Jorgensen | last post by:
In a recent thread, RKC (correctly, I believe), took issue with my use of multiple parameters in a Property Let procedure to pass dimensional arguments on the basis that, although it works, it's...
12
by: Mark | last post by:
Apologies for the lengthy posting.... In a previous posting:...
2
by: SouthSpawn | last post by:
I have the following situation. I am creating my own user control. This asp.net user control will have a method called "Read". When this method is being called from the page. It will read line...
2
by: Mark A. Sam | last post by:
Hello, I want to use a literal control to provide information about people listed on a webpage, where the control is on the same line as the person it addresses, so that I have a button, the...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.