473,786 Members | 2,866 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert a carriage return in a JavaScript string

Hi,

I've got some JavaScript inserted within a PHP echo instruction:
<?php>
echo " ... javascript ...."
<?>

This context may be important, I don't know...
At some point within the JavaScript, I want to add a carriage return at
the end of a field value:
str = str + '\n';

but this writting does not work, because the Javascript produced in the
html page gives:
str = str + '
'
How to do this?

Thanks.

Herve.

Sep 12 '06 #1
2 19078
"yellowtek" <hm*****@tele2. frwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
Hi,

I've got some JavaScript inserted within a PHP echo instruction:
<?php>
echo " ... javascript ...."
<?>

This context may be important, I don't know...
At some point within the JavaScript, I want to add a carriage return at
the end of a field value:
str = str + '\n';

but this writting does not work, because the Javascript produced in the
html page gives:
str = str + '
'
How to do this?
FYI:
str +' "\n"
is the same as
str = str + '\n';

Depending on your usage you may have to "escape"
the backslash; for example \\n.

However, "<br>" may be applicable instead.

What causes the "Javascript produced in the html page"?

Show us your code...

Sep 12 '06 #2
The javascript "produced" is what you get in the browser as a source
code when the PHP page is executed, that is:
echo "... javascript..... ";

And the reason of the insertion of JavaScript within this PHP echo is
the share of PHP constants:
<?php>
include ("inc/constants.inc.p hp");
echo "
str = str + '".A_CONSTANT." ';
";
<?>

I will try the double \; that might be the solution.
Thanks.

McKirahan a écrit :
"yellowtek" <hm*****@tele2. frwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
Hi,

I've got some JavaScript inserted within a PHP echo instruction:
<?php>
echo " ... javascript ...."
<?>

This context may be important, I don't know...
At some point within the JavaScript, I want to add a carriage return at
the end of a field value:
str = str + '\n';

but this writting does not work, because the Javascript produced in the
html page gives:
str = str + '
'
How to do this?

FYI:
str +' "\n"
is the same as
str = str + '\n';

Depending on your usage you may have to "escape"
the backslash; for example \\n.

However, "<br>" may be applicable instead.

What causes the "Javascript produced in the html page"?

Show us your code...
Sep 12 '06 #3

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

Similar topics

4
7432
by: Lauren Quantrell | last post by:
I have created the following trigger: CREATE TRIGGER ON OutputTable FOR INSERT AS Declare @filename nvarchar(35) Declare @filecontents nvarchar(2000) Declare @strcmdshell varchar(150)
1
8471
by: Paradigm | last post by:
I want to insert a carriage return into a text field. I am using insert into and /n for newline. The MYSQL database is accessed by a MS Access front end and the text field appears with a small square where the new line should be. It appears that the /n is interpreted in Access differently. Is there a way of putting a carriage return into the field so that it is seen as such by Accesss? Alex
2
4131
by: Andrew Chanter | last post by:
I have a VBA function that returns a string including "vbcr" (VB Carriage Return) to seperate a list into multiple rows, eg Item1 & vbcr & Item2 & vbcr & Item3 This works as planned in the immediate window, producing a list where a Carriage Return follows each item. But when I output the result into either an Access query or form, instead of carriage returns I get little square symbols between each of the items. Is anyone able to tell...
2
2337
by: sys | last post by:
I have a web method that returns a string. When I return a string that has a carriage return and line feed in it ("\r\n") on the client side I only receive a string including the line feed ("\n"). The carriage return disappeared. Thanks for any help.
3
3383
by: Dinsdale | last post by:
I have an xml file that is read into an object using serialization. One of the objects has a string field called delimeter that I want to contain a carriage return. Instead of trying to include the carriage return, I used "\r" thinking that when it was read back into the object it would be interpreted as a carriage return. Instead, I am getting the string literal instead of the escape sequence. Does anybody have a slick way of telling it...
9
2722
by: sunita jadhav | last post by:
my question is if i type in html textbox on key press event suppose i type 12345 values in textbox then i delete or edit any value of text box suppose i edit 3 and i insert the value 6 at 3 but i have face problem that is if i insert 6 at 3 this value is not insert at 3 it insert last positon i.e after last value .In given example the value is appned or insert after 5 then output is 12456 but i have want the output 12645 and i also give the...
4
3385
by: Kevin Vogler | last post by:
I'm still feeling my way around XML parsing and have an app that uses XML reader and works fine as long as the XML is pretty but doesn't find all the elements when the XML is all on a single line without the carriage returns after each element. As I understand it XMLReader uses the carriage return as a stop for each read. Before I start to rewrite this, I would like to know if there's a way to deal with this with XMLReader or will using...
0
9650
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.