473,624 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

textarea problem when sending content to javascript function

Mabee you guys can help me with this.
I have a form with enctype="multip art/form-data" that has a textarea in
it as well as file upload. The text area is for a description of the
file.

If someone uses the enter key to make 2 lines in the text area when it
is submitted it is stored in mysql database with (i guess) a line break
\n? When i pull the data out of mysql to put back into the textarea i
use the javascript function setup_update_fo rm('<?=$docrow[0]?>',
'<?=$docrow[2]?>', '<?=$docrow[3])?>'"and when this renders to html
it put a new line in the call variable and makes it look something like
this:

setup_update_fo rm('18', '20', 'This is the first line
and this is the second')

Obviously javascript doesnt like this. I have also tried
setup_update_fo rm('<?=$docrow[0]?>', '<?=$docrow[2]?>',
'<?=str_replace ("\n", "", $docrow[3])?>')"but it does absolutely
nothing difrent.
I have also tried nl2br() but all that does it add a <brand keep the
newline.

Any help is apreciated.

Jan 8 '07 #1
4 2565
On Jan 8, 11:04 am, "Nate12o6" <Baxter...@msn. comwrote:
Obviously javascript doesnt like this. I have also tried
setup_update_fo rm('<?=$docrow[0]?>', '<?=$docrow[2]?>',
'<?=str_replace ("\n", "", $docrow[3])?>')"but it does absolutely
nothing difrent.
I have also tried nl2br() but all that does it add a <brand keep the
newline.
You're on the right track. I'm not sure what server-side language
you're using (PHP?), but the newline character is just that - a
character. You should use a character replace function or a regular
expression to replace newlines in a string.

Cheers
Chad

Jan 8 '07 #2
"Nate12o6" <Ba*******@msn. comwrote in news:1168279469 .118325.300180
@s80g2000cwa.go oglegroups.com:
Mabee you guys can help me with this.
I have a form with enctype="multip art/form-data" that has a textarea in
it as well as file upload. The text area is for a description of the
file.

If someone uses the enter key to make 2 lines in the text area when it
is submitted it is stored in mysql database with (i guess) a line break
\n? When i pull the data out of mysql to put back into the textarea i
use the javascript function setup_update_fo rm('<?=$docrow[0]?>',
'<?=$docrow[2]?>', '<?=$docrow[3])?>'"and when this renders to html
it put a new line in the call variable and makes it look something like
this:

setup_update_fo rm('18', '20', 'This is the first line
and this is the second')

Obviously javascript doesnt like this. I have also tried
setup_update_fo rm('<?=$docrow[0]?>', '<?=$docrow[2]?>',
'<?=str_replace ("\n", "", $docrow[3])?>')"but it does absolutely
nothing difrent.
I have also tried nl2br() but all that does it add a <brand keep the
newline.

Any help is apreciated.
You're almost there. Replacing the character that causes the newline is
the right approach. However, first you need to figure out just what that
character is.

First of all, how is your textarea defined? Are you using the
(unofficial) attribue wrap = hard | soft | off ? (If set to hard, try
setting to soft. If not, forget about it.)

Second, where is the newline character being added to the textstring?
PHP? The database? Can you change that behavior?

Third, if you're stuck with the character arriving in the textstring,
you'll need to figure out exactly which character it is. Write a test
page, using PHP and the database to write the string directly to the web
page, no JS involved. Examine the page source to find the character and
figure out its ASCII value. THEN you'll know exactly which character to
replace using JS.

Jan 8 '07 #3
Wrap is not being defined, the newline is comeing from the user input
into the textarea.
Is there a PHP function that will give me every ascii value from a
string so i can figure out what that newline char is?

Thanks for the help!

Jim Land (NO SPAM) wrote:
"Nate12o6" <Ba*******@msn. comwrote in news:1168279469 .118325.300180
@s80g2000cwa.go oglegroups.com:
Mabee you guys can help me with this.
I have a form with enctype="multip art/form-data" that has a textarea in
it as well as file upload. The text area is for a description of the
file.

If someone uses the enter key to make 2 lines in the text area when it
is submitted it is stored in mysql database with (i guess) a line break
\n? When i pull the data out of mysql to put back into the textarea i
use the javascript function setup_update_fo rm('<?=$docrow[0]?>',
'<?=$docrow[2]?>', '<?=$docrow[3])?>'"and when this renders to html
it put a new line in the call variable and makes it look something like
this:

setup_update_fo rm('18', '20', 'This is the first line
and this is the second')

Obviously javascript doesnt like this. I have also tried
setup_update_fo rm('<?=$docrow[0]?>', '<?=$docrow[2]?>',
'<?=str_replace ("\n", "", $docrow[3])?>')"but it does absolutely
nothing difrent.
I have also tried nl2br() but all that does it add a <brand keep the
newline.

Any help is apreciated.

You're almost there. Replacing the character that causes the newline is
the right approach. However, first you need to figure out just what that
character is.

First of all, how is your textarea defined? Are you using the
(unofficial) attribue wrap = hard | soft | off ? (If set to hard, try
setting to soft. If not, forget about it.)

Second, where is the newline character being added to the textstring?
PHP? The database? Can you change that behavior?

Third, if you're stuck with the character arriving in the textstring,
you'll need to figure out exactly which character it is. Write a test
page, using PHP and the database to write the string directly to the web
page, no JS involved. Examine the page source to find the character and
figure out its ASCII value. THEN you'll know exactly which character to
replace using JS.
Jan 8 '07 #4
"Nate12o6" <Ba*******@msn. comwrote in
news:11******** **************@ v33g2000cwv.goo glegroups.com:
Jim Land (NO SPAM) wrote:
>"Nate12o6" <Ba*******@msn. comwrote in news:1168279469 .118325.300180
@s80g2000cwa.g ooglegroups.com :
Mabee you guys can help me with this.
I have a form with enctype="multip art/form-data" that has a
textarea in it as well as file upload. The text area is for a
description of the file.

If someone uses the enter key to make 2 lines in the text area when
it is submitted it is stored in mysql database with (i guess) a
line break \n? When i pull the data out of mysql to put back into
the textarea i use the javascript function
setup_update_fo rm('<?=$docrow[0]?>', '<?=$docrow[2]?>',
'<?=$docrow[3])?>'"and when this renders to html it put a new
line in the call variable and makes it look something like this:

setup_update_fo rm('18', '20', 'This is the first line
and this is the second')

Obviously javascript doesnt like this. I have also tried
setup_update_fo rm('<?=$docrow[0]?>', '<?=$docrow[2]?>',
'<?=str_replace ("\n", "", $docrow[3])?>')"but it does absolutely
nothing difrent.
I have also tried nl2br() but all that does it add a <brand keep
the newline.

Any help is apreciated.

You're almost there. Replacing the character that causes the newline
is the right approach. However, first you need to figure out just
what that character is.

First of all, how is your textarea defined? Are you using the
(unofficial) attribue wrap = hard | soft | off ? (If set to hard,
try setting to soft. If not, forget about it.)

Second, where is the newline character being added to the textstring?
PHP? The database? Can you change that behavior?

Third, if you're stuck with the character arriving in the textstring,
you'll need to figure out exactly which character it is. Write a
test page, using PHP and the database to write the string directly to
the web page, no JS involved. Examine the page source to find the
character and figure out its ASCII value. THEN you'll know exactly
which character to replace using JS.


Wrap is not being defined, the newline is comeing from the user input
into the textarea.
Is there a PHP function that will give me every ascii value from a
string so i can figure out what that newline char is?
Well, this *is* a JS newsgroup, so best to ask that question in a PHP
newsgroup. ;-)

But.... if the user is inserting the newline into the textarea, then it's
likely ASCII character 10 (FF) or char 13 + char 10 (MSIE). So try
replacing char 13 and char 10 with '' in your textarea string and see if
that fixes things.

Jan 9 '07 #5

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

Similar topics

2
5212
by: Charles | last post by:
Hi folks, I am desperatly looking for a WYSIWYG HTML editor for a textarea, using JavaScript and that'll work with Opera. I want this editor to use for a webmail program in PHP, and allow users to send HTML email. All HTML editors I found out on the web work for most browsers except Opera. Does any of you guys know of an Opera-friendly editor? That would be great... Thanks,
5
12132
by: Jesper Rønn-Jensen | last post by:
I have a textarea that must be limited to 70 characters. No big deal -- at least so I thought. * Textarea must not exceed 70 characters * Exceeding content must be cut off * Must work on input by keyboard (keypress, keyup events) * Must work on pasted input from context menu * Must work on pasted input via CTRL+V and similar * Must work on pasted input via browsers menu>Edit>Paste * Must work in Mozilla + IE and coded via W3C standards
2
9652
by: danielboendergaard | last post by:
Hey Im making a homepage in php. I use a html form to put data into mysql and i want to make some buttons which inserts user input values into a textarea. I have used a button like this: <input type="button" value="Add Quote" onclick="document.getElementById('nyhed').value+=''"> The button works fine and insterts into the textarea. Although I want to make a button which onclick asks the user for a
2
2197
by: Ivor Somerset | last post by:
Hello, At http://tuckey.org/textareasizer/ there's a script that autoresized the height of the textareas in a form so that it matches the content. This is a very interesting capability, however that script has a big drawback: the number of rows (lines) needed to fit the content is an estimate (based on the "cols" attribute in "textarea") and in most cases the textarea box will not match exactly the content. So I've thought of an...
6
26986
by: gilbert.george | last post by:
Hi, I am setting the width of a textarea using the style.width to ensure the textarea is exactly the right width. I want to set the height/rows of the textarea depending on it's contents (so that it dynamically grows and shrinks as the contents alter) however I can not see a way to calculate the required number of rows (or height) for a given content string.
23
3759
by: Angus | last post by:
Hello I have a DIV with various elements eg: <div ARID="8" ARType="Char" ARDBN="Short Description"> <label class="label f9" for="arid8"Short Description</label> <textarea class="text sr " wrap="off" id="arid8" rows=1></textarea> </div> I have a variable, divs, which contains the DIV's and divs contains
1
2210
by: nehacredo | last post by:
hi all.. when im copying a PDF file content to a textarea using JavaScript i am getting an error "Automation Server Can't creat object" why it is coming... im copying my code here. <html> <head><title>PDF File Load document</title> <script language="JavaScript"> function loadpdf() { var PDF=new ActiveXObject("pdf.PdfCtrl");
2
3070
by: thuythu | last post by:
Please help me.... I used and Javascript to view the data. But when i click button open a popup windows, then select data and click save button. The popup close and return the main page, but the textbox value in the main page is undefined ---------------------------------------- here are code main page: ------------------------------------------- <script language="JavaScript"> var thedata; var newwin; var thenumber; function...
8
2511
by: Sandy Tipper | last post by:
I have never had a textarea content change, in any browser. On several different projects. With javascript enabled (other stuff works.) I have read lots, and everyone says it should work. Can anyone tell my what's wrong with the following code? (I was trying to create a simple demo example. The alerts are there just to help find out where it fails. The onClick isn't even getting executed, even though I get it to work elsewhere.) ------...
0
8614
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
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
7153
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...
1
6107
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
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
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
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.